#if (FEATURE_MODE == 0)
#if defined(TSINGMA_MX) || defined(TSINGMA_GX) || defined(ARCTIC)

#include "ctc_error.h"
#include "ctc_diag.h"
#include "sys_usw_diag.h"
#include "sys_usw_common.h"
#include "sys_usw_mchip.h"
#include "sys_usw_register.h"
#include "sys_tmm_discard_type.h"
#include "sys_usw_flexe.h"
#include "sys_usw_mchip.h"
#include "drv_api.h"
#include "usw/include/drv_enum.h"
#include "usw/include/drv_common.h"
#include "sys_usw_acl_api.h"
#include "sys_usw_qos_api.h"

extern int32
sys_usw_diag_drop_hash_update_count(uint8 lchip, uint32 port, uint16 reason, uint64 count);
extern int32
sys_tmm_diag_get_queu_io(uint8 lchip, sys_traverse_t* data);


#define DIAG_IGS_ACL_LKUP_NUM       16
#define DIAG_LPM_TCAM_LOCAL_BIT_LEN    14
#define DIAG_LPM_TCAM_MAX_ENTRY_NUM    8192
/*egress scl key size in word*/
#define DIAF_EGS_SCL_KEY_SIZE       3
#define DIAG_LOOKUP_CONFLICT "CONFLICT"
#define DIAG_LOOKUP_DEFAULT "HIT-DEFAULT-ENTRY"
#define DIAG_LOOKUP_HIT  "HIT"
#define DIAG_LOOKUP_HIT_NONE "HIT-NONE"
#define DIAG_ENABLE "ENABLE"
#define DIAG_DISABLE    "DISABLE"
#define DIAG_YES    "Y"
#define DIAG_NO     "N"

#define DIAG_DECODE_VLAN_ID(vlan_tag)       (vlan_tag & 0xFFF)
#define DIAG_DECODE_VLAN_COS(vlan_tag)      ((vlan_tag >> 13) & 0x7)
#define DIAG_DECODE_VLAN_CFI(vlan_tag)      ((vlan_tag >> 12) & 0x1)
#define DIAG_ENCODE_VLAN_TAG(id, cos, cfi)  ((cfi << 12) | (cos << 13) | id)

typedef struct sys_diag_pkt_trace_table_s
{
    uint32 table;
    uint32 field;
}sys_diag_pkt_trace_table_t;

enum sys_tmm_diag_l3da_key_type_e
{
    SYS_TMM_DIAG_L3DA_TYPE_IPV4UC,
    SYS_TMM_DIAG_L3DA_TYPE_IPV6UC,
    SYS_TMM_DIAG_L3DA_TYPE_IPV4MC,
    SYS_TMM_DIAG_L3DA_TYPE_IPV6MC,
    SYS_TMM_DIAG_L3DA_TYPE_FCOE,
    SYS_TMM_DIAG_L3DA_TYPE_TRILLUC,
    SYS_TMM_DIAG_L3DA_TYPE_TRILLMC,

    SYS_TMM_DIAG_L3DA_TYPE_MAX
};
typedef  enum sys_tmm_diag_l3da_key_type_e sys_tmm_diag_l3da_key_type_t;

enum sys_tmm_diag_l3sa_key_type_e
{
    SYS_TMM_DIAG_L3SA_TYPE_IPV4RPF,
    SYS_TMM_DIAG_L3SA_TYPE_IPV6RPF,
    SYS_TMM_DIAG_L3SA_TYPE_IPV4PBR,
    SYS_TMM_DIAG_L3SA_TYPE_IPV6PBR,
    SYS_TMM_DIAG_L3SA_TYPE_IPV4NATSA,
    SYS_TMM_DIAG_L3SA_TYPE_IPV6NATSA,
    SYS_TMM_DIAG_L3SA_TYPE_FCOERPF,

    SYS_TMM_DIAG_L3SA_TYPE_MAX
};
typedef  enum sys_tmm_diag_l3sa_key_type_e sys_tmm_diag_l3sa_key_type_t;

#define DIAG_VLAN_ACTION_NONE              0
#define DIAG_VLAN_ACTION_ADD               1
#define DIAG_VLAN_ACTION_DELETE            2
#define DIAG_VLAN_ACTION_MODIFY            3

STATIC int32
_sys_tmm_diag_pkt_tracce_drop_map(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt, uint32 discard, uint32 discard_type)
{
    uint8 pos = p_rslt->position;
    const char* drop_desc = NULL;
    const char* discard_desc = NULL;
    uint16 str_desc_len = 0;
    uint32 temp_map = (pos << 16) | discard_type;

    if (0 == discard || temp_map == p_usw_diag_master[lchip]->cur_discard_type_map)
    {
        return CTC_E_NONE;
    }
    p_rslt->dest_type = CTC_DIAG_DEST_DROP;

    if (CTC_DIAG_TRACE_POS_IPE == pos)
    {
        discard_desc = sys_tmm_get_discard_type_desc(discard_type + SYS_TMM_DISCARD_IPE_START);
        sys_tmm_map_drop_reason_sys_to_ctc(discard_type + SYS_TMM_DISCARD_IPE_START, &p_rslt->drop_reason);
    }
    else if (pos == CTC_DIAG_TRACE_POS_EPE)
    {
        discard_desc = sys_tmm_get_discard_type_desc(discard_type + SYS_TMM_DISCARD_EPE_START);
        sys_tmm_map_drop_reason_sys_to_ctc(discard_type + SYS_TMM_DISCARD_EPE_START, &p_rslt->drop_reason);
    }
    else
    {
        discard_desc = "unknown";
    }
    drop_desc = sys_usw_register_get_reason_desc(lchip, p_rslt->drop_reason);
    p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_DROP_REASON;
    p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_DROP_DESC;
    str_desc_len = sal_strlen(drop_desc);
    if (str_desc_len)
    {
        sal_memcpy(p_rslt->drop_desc, drop_desc, (str_desc_len < CTC_DIAG_REASON_DESC_LEN) ? str_desc_len : CTC_DIAG_REASON_DESC_LEN);
    }
    DIAG_INFO_CHAR(pos, (CTC_DIAG_TRACE_POS_IPE == pos) ? "ipe-drop" : "epe-drop", discard_desc)
    p_usw_diag_master[lchip]->cur_discard_type_map = temp_map;
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_tracce_exception_map(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt,
                                          uint32 excp, uint32 excp_index, uint32 excp_sub_index)
{
    uint8 pos = p_rslt->position;
    uint32 temp_map = (excp_index << 16) | excp_sub_index;
    char* exception_desc[] =
    {
        "Reserved",         /* IPEEXCEPTIONINDEX_RESERVED               CBit(3,'h',"0", 1)*/
        "Bridge exception", /* IPEEXCEPTIONINDEX_BRIDGE_EXCEPTION       CBit(3,'h',"1", 1)*/
        "Route exception",  /* IPEEXCEPTIONINDEX_ROUTE_EXCEPTION        CBit(3,'h',"2", 1)*/
        "Other exception",  /* IPEEXCEPTIONINDEX_OTHER_EXCEPTION        CBit(3,'h',"3", 1)*/
        "Unknow" ,
        "Unknow" ,
        "Unknow" ,
        "Unknow" 
    };

    if (0 == excp || temp_map == p_usw_diag_master[lchip]->cur_exception_map)
    {
        return CTC_E_NONE;
    }

    p_rslt->dest_type = CTC_DIAG_DEST_CPU;
    DIAG_INFO_CHAR(pos, "exception-type",STR_ARRAY(exception_desc, excp_index))
    DIAG_INFO_UINT32(pos, "exception-index", excp_index)
    DIAG_INFO_UINT32(pos, "exception-sub-index", excp_sub_index)
    p_usw_diag_master[lchip]->cur_exception_map = temp_map;
    return CTC_E_NONE;
}


STATIC int32
_sys_tmm_diag_pkt_trace_get_parser_info(uint8 lchip, uint8 type, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint32 value1 = 0;
    char str[64] = {0};
    hw_mac_addr_t hw_mac = {0};
    ip_addr_t hw_ipv4 = 0;
    ipv6_addr_t hw_ipv6 = {0};
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    char* str_parser[] = {"1st Parsing", "2nd Parsing", "Egress Parsing"};
    char* str_l3_type[] = {"NONE", "IP", "IPV4", "IPV6", "MPLS", "MPLSUP", "ARP", "FCOE", "TRILL",
                           "ETHEROAM", "SLOWPROTO", "RESERVED", "PTP", "DOT1AE", "SATPDU", "FLEXIBLE"};

    char* str_l4_type[] = {"NONE", "TCP", "GRE", "UDP", "IPINIP", "V6INIP", "ICMP", "IGMP", "IPINV6",
                           "RESERVED", "ACHOAM", "V6INV6", "RDP", "SCTP", "DCCP", "FLEXIBLE"};
    char *sys_diag_int_encap_type[] = {"", "TCP-RAW", "TCP-PROBE", "UDP-RAW", "UDP-PROBE"};
    ds_t parser_result_tmp;
    ParserResult_m parser_result;

    sal_memset(&parser_result_tmp, 0, sizeof(DbgParserFromIpeHdrAdjInfo_m));
    sal_memset(&parser_result, 0, sizeof(ParserResult_m));
    if (0 == type)       /*ipe 1st parser*/
    {
        cmd = DRV_IOR(DbgParserFromIpeHdrAdjInfo_t, DRV_ENTRY_FLAG);
    }
    else if (1 == type)  /*ipe 2nd parser*/
    {
        cmd = DRV_IOR(DbgIpeMplsDecapInfo_t, DbgIpeMplsDecapInfo_secondParserEn_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
        if(!value)
        {
            return CTC_E_NONE;
        }
        cmd = DRV_IOR(DbgParserFromIpeIntfInfo_t, DRV_ENTRY_FLAG);
    }
    else if (2 == type)  /*epe parser*/
    {
        cmd = DRV_IOR(DbgParserFromEpeHdrAdjInfo_t, DRV_ENTRY_FLAG);
    }
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &parser_result_tmp));

    if(!GetDbgParserFromIpeHdrAdjInfo(V, valid_f, &parser_result_tmp))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = (2 == type) ? CTC_DIAG_TRACE_POS_EPE : CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, STR_ARRAY(str_parser,type))
    GetDbgParserFromIpeHdrAdjInfo(A, data_f, &parser_result_tmp, &parser_result);

    GetParserResult(A, macDa_f,        &parser_result, hw_mac);
    DIAG_INFO_MAC(pos, "mac-da", hw_mac)
    GetParserResult(A, macSa_f,        &parser_result, hw_mac);
    DIAG_INFO_MAC(pos, "mac-sa", hw_mac)

    if (GetParserResult(V, svlanIdValid_f, &parser_result))
    {
        DIAG_INFO_UINT32(pos, "svlan-id", GetParserResult(V, svlanId_f, &parser_result))
        DIAG_INFO_UINT32(pos, "stag-cos", GetParserResult(V, stagCos_f, &parser_result))
    }
    if (GetParserResult(V, cvlanIdValid_f, &parser_result))
    {
        DIAG_INFO_UINT32(pos, "cvlan-id", GetParserResult(V, cvlanId_f, &parser_result))
        DIAG_INFO_UINT32(pos, "ctag-cos", GetParserResult(V, ctagCos_f, &parser_result))
    }

    DIAG_INFO_U32_HEX(pos, "ether-type", GetParserResult(V, etherType_f, &parser_result))
    DIAG_INFO_UINT32(pos, "layer2-ext-type", GetParserResult(V, layer2ExtType_f, &parser_result))
    value = GetParserResult(V, layer3Type_f, &parser_result);
    if (value < MAX_CTC_PARSER_L3_TYPE)
    {
        sal_sprintf(str, "L3TYPE_%s",STR_ARRAY(str_l3_type,value));
        DIAG_INFO_CHAR(pos, "layer3-type", str)
    }
    switch (value)
    {
        case CTC_PARSER_L3_TYPE_IPV4:
            DIAG_INFO_U32_HEX(pos, "ip-protocol", GetParserResult(V, layer3HeaderProtocol_f, &parser_result))
            GetParserResult(A, uL3Dest_gIpv4_ipDa_f,   &parser_result, &hw_ipv4);
            DIAG_INFO_IP4(pos, "ip-da", hw_ipv4)
            GetParserResult(A, uL3Source_gIpv4_ipSa_f, &parser_result, &hw_ipv4);
            DIAG_INFO_IP4(pos, "ip-sa", hw_ipv4)
            break;
        case CTC_PARSER_L3_TYPE_IPV6:
            DIAG_INFO_U32_HEX(pos, "ip-protocol", GetParserResult(V, layer3HeaderProtocol_f, &parser_result))
            GetParserResult(A, uL3Dest_gIpv6_ipDa_f,   &parser_result, hw_ipv6);
            DIAG_INFO_IP6(pos, "ip6-da", hw_ipv6)
            GetParserResult(A, uL3Source_gIpv6_ipSa_f, &parser_result, hw_ipv6);
            DIAG_INFO_IP6(pos, "ip6-sa", hw_ipv6)
            break;
        case CTC_PARSER_L3_TYPE_MPLS:
            value1 = GetParserResult(V, uL3Tos_gMpls_labelNum_f, &parser_result);
            switch (value1)
            {
                case 8:
                    GetParserResult(A, uL3Source_gMpls_mplsLabel7_f, &parser_result, &value);
                    DIAG_INFO_UINT32(pos, "mpls-label-7", value >> 12);
                case 7:
                    GetParserResult(A, uL3Source_gMpls_mplsLabel6_f, &parser_result, &value);
                    DIAG_INFO_UINT32(pos, "mpls-label-6", value >> 12);
                case 6:
                    GetParserResult(A, uL3Source_gMpls_mplsLabel5_f, &parser_result, &value);
                    DIAG_INFO_UINT32(pos, "mpls-label-5", value >> 12);
                case 5:
                    GetParserResult(A, uL3Source_gMpls_mplsLabel4_f, &parser_result, &value);
                    DIAG_INFO_UINT32(pos, "mpls-label-4", value >> 12);
                case 4:
                    GetParserResult(A, uL3Dest_gMpls_mplsLabel3_f,   &parser_result, &value);
                    DIAG_INFO_UINT32(pos, "mpls-label-3", value >> 12);
                case 3:
                    GetParserResult(A, uL3Dest_gMpls_mplsLabel2_f,   &parser_result, &value);
                    DIAG_INFO_UINT32(pos, "mpls-label-2", value >> 12);
                case 2:
                    GetParserResult(A, uL3Dest_gMpls_mplsLabel1_f,   &parser_result, &value);
                    DIAG_INFO_UINT32(pos, "mpls-label-1", value >> 12);
                case 1:
                    GetParserResult(A, uL3Dest_gMpls_mplsLabel0_f,   &parser_result, &value);
                    DIAG_INFO_UINT32(pos, "mpls-label-0", value >> 12);
                case 0:
                    break;
            }
            break;
        case CTC_PARSER_L3_TYPE_ARP:
            DIAG_INFO_UINT32(pos, "arp-op-code", GetParserResult(V, uL3Dest_gArp_arpOpCode_f, &parser_result))
            DIAG_INFO_UINT32(pos, "arp-protocol-type", GetParserResult(V, uL3Source_gArp_protocolType_f, &parser_result))
            GetParserResult(A, uL3Dest_gArp_targetIp_f, &parser_result, &hw_ipv4);
            DIAG_INFO_IP4(pos, "arp-target-ip", hw_ipv4)
            GetParserResult(A, uL3Source_gArp_senderIp_f, &parser_result, &hw_ipv4);
            DIAG_INFO_IP4(pos, "arp-sender-ip", hw_ipv4)
            GetParserResult(A, uL3Dest_gArp_targetMac_f, &parser_result, hw_mac);
            DIAG_INFO_MAC(pos, "arp-target-mac", hw_mac)
            GetParserResult(A, uL3Source_gArp_senderMac_f, &parser_result, hw_mac);
            DIAG_INFO_MAC(pos, "arp-sender-mac", hw_mac)
            break;
        case CTC_PARSER_L3_TYPE_FCOE:
            DIAG_INFO_UINT32(pos, "fcoe-did", GetParserResult(V, uL3Dest_gFcoe_fcoeDid_f, &parser_result))
            DIAG_INFO_UINT32(pos, "fcoe-sid", GetParserResult(V, uL3Source_gFcoe_fcoeSid_f, &parser_result))
            break;
        case CTC_PARSER_L3_TYPE_TRILL:
            DIAG_INFO_U32_HEX(pos, "ingress-nickname", GetParserResult(V, uL3Source_gTrill_ingressNickname_f, &parser_result))
            DIAG_INFO_U32_HEX(pos, "egress-nickname", GetParserResult(V, uL3Dest_gTrill_egressNickname_f, &parser_result))
            DIAG_INFO_UINT32(pos, "trill-is-esadi", GetParserResult(V, uL3Dest_gTrill_isEsadi_f, &parser_result))
            DIAG_INFO_UINT32(pos, "trill-is-bfd", GetParserResult(V, uL3Dest_gTrill_isTrillBfd_f, &parser_result))
            DIAG_INFO_UINT32(pos, "trill-is-bfd-echo", GetParserResult(V, uL3Dest_gTrill_isTrillBfdEcho_f, &parser_result))
            DIAG_INFO_UINT32(pos, "is-channel", GetParserResult(V, uL3Dest_gTrill_isTrillChannel_f, &parser_result))
            DIAG_INFO_UINT32(pos, "bfd-my-discrim", GetParserResult(V, uL3Dest_gTrill_trillBfdMyDiscriminator_f, &parser_result))
            if (GetParserResult(V, uL3Dest_gTrill_trillInnerVlanValid_f, &parser_result))
            {
                DIAG_INFO_UINT32(pos, "inner-vlan-id", GetParserResult(V, uL3Dest_gTrill_trillInnerVlanId_f, &parser_result))
            }
            DIAG_INFO_UINT32(pos, "trill-length", GetParserResult(V, uL3Dest_gTrill_trillLength_f, &parser_result))
            DIAG_INFO_UINT32(pos, "multi-hop", GetParserResult(V, uL3Dest_gTrill_trillMultiHop_f, &parser_result))
            DIAG_INFO_UINT32(pos, "trill-multicast", GetParserResult(V, uL3Dest_gTrill_trillMulticast_f, &parser_result))
            DIAG_INFO_UINT32(pos, "trill-version", GetParserResult(V, uL3Dest_gTrill_trillVersion_f, &parser_result))
            break;
        case CTC_PARSER_L3_TYPE_ETHER_OAM:
            DIAG_INFO_UINT32(pos, "ether-oam-level", GetParserResult(V, uL3Dest_gEtherOam_etherOamLevel_f, &parser_result))
            DIAG_INFO_UINT32(pos, "ether-oam-op-code", GetParserResult(V, uL3Dest_gEtherOam_etherOamOpCode_f, &parser_result))
            DIAG_INFO_UINT32(pos, "ether-oam-version", GetParserResult(V, uL3Dest_gEtherOam_etherOamVersion_f, &parser_result))
            break;
        case CTC_PARSER_L3_TYPE_SLOW_PROTO:
            DIAG_INFO_UINT32(pos, "slow-proto-code", GetParserResult(V, uL3Dest_gSlowProto_slowProtocolCode_f, &parser_result))
            DIAG_INFO_U32_HEX(pos, "slow-proto-flags", GetParserResult(V, uL3Dest_gSlowProto_slowProtocolFlags_f, &parser_result))
            DIAG_INFO_UINT32(pos, "slow-proto-subtype", GetParserResult(V, uL3Dest_gSlowProto_slowProtocolSubType_f, &parser_result))
            break;
        case CTC_PARSER_L3_TYPE_PTP:
            DIAG_INFO_UINT32(pos, "ptp-message-type", GetParserResult(V, uL3Dest_gPtp_ptpMessageType_f, &parser_result))
            DIAG_INFO_UINT32(pos, "ptp-version", GetParserResult(V, uL3Dest_gPtp_ptpVersion_f, &parser_result))
            break;
        case CTC_PARSER_L3_TYPE_SATPDU:
            {
                uint64 val_64 = 0;
                uint32 array_value[2] = {0};
                DIAG_INFO_UINT32(pos, "satpdu-mef-oui", GetParserResult(V, uL3Dest_gSatPdu_mefOui_f, &parser_result))
                DIAG_INFO_UINT32(pos, "satpdu-oui-subtype", GetParserResult(V, uL3Dest_gSatPdu_ouiSubType_f, &parser_result))
                GetParserResult(A, uL3Dest_gSatPdu_pduByte_f, &parser_result, array_value);
                val_64 = array_value[1];
                val_64 = val_64 << 32 | array_value[0];
                DIAG_INFO_U64_HEX(pos, "satpdu-pdu-byte", val_64)
            }
            break;
        default:
            break;
    }
    DIAG_INFO_UINT32(pos, "layer3-ext-type", GetParserResult(V, layer3ExtType_f, &parser_result))
    value = GetParserResult(V, layer4Type_f, &parser_result);
    if (value < MAX_CTC_PARSER_L4_TYPE)
    {
        sal_sprintf(str, "L4TYPE_%s", STR_ARRAY(str_l4_type,value));
        DIAG_INFO_CHAR(pos, "layer4-type", str)
    }
    if (value == DRV_ENUM(DRV_PARSER_L4_TYPE_GRE))
    {
        DIAG_INFO_UINT32(pos, "gre-flags", GetParserResult(V, uL4Source_gGre_greFlags_f, &parser_result))
        DIAG_INFO_U32_HEX(pos, "gre-proto-type", GetParserResult(V, uL4Dest_gGre_greProtocolType_f, &parser_result))
        DIAG_INFO_U32_HEX(pos, "gre-key", GetParserResult(V, uL4UserData_gGre_greKey_f, &parser_result))
    }
    else if (value == DRV_ENUM(DRV_PARSER_L4_TYPE_UDP))
    {
        DIAG_INFO_UINT32(pos, "l4-src-port", GetParserResult(V, uL4Source_gPort_l4SourcePort_f, &parser_result))
        DIAG_INFO_UINT32(pos, "l4-dst-port", GetParserResult(V, uL4Dest_gPort_l4DestPort_f, &parser_result))
    }
    switch (value)
    {
        case CTC_PARSER_L4_TYPE_TCP:
        case CTC_PARSER_L4_TYPE_RDP:
        case CTC_PARSER_L4_TYPE_SCTP:
        case CTC_PARSER_L4_TYPE_DCCP:
            DIAG_INFO_UINT32(pos, "l4-src-port", GetParserResult(V, uL4Source_gPort_l4SourcePort_f, &parser_result))
            DIAG_INFO_UINT32(pos, "l4-dst-port", GetParserResult(V, uL4Dest_gPort_l4DestPort_f, &parser_result))
            break;
        default:
            break;
    }
    value = GetParserResult(V, lengthError_f, &parser_result);
    if (CTC_IS_BIT_SET(value, 0))
    {
        DIAG_INFO_CHAR(pos, "len-error", "layer2")
    }
    if (CTC_IS_BIT_SET(value, 1))
    {
        DIAG_INFO_CHAR(pos, "len-error", "layer3")
    }
    if (CTC_IS_BIT_SET(value, 2))
    {
        DIAG_INFO_CHAR(pos, "len-error", "layer4")
    }
    value = GetParserResult(V, intEncapType_f, &parser_result);
    if (DIAG_INT_ENCAP_TYPE_NONE != value)
    {
        DIAG_INFO_CHAR(pos, "int-encap-type", STR_ARRAY(sys_diag_int_encap_type,value));
    }
    DIAG_INFO_UINT32(pos, "l2-decoder-index", GetParserResult(V, l2DecoderIndex_f, &parser_result))
    DIAG_INFO_UINT32(pos, "l3-decoder-index", GetParserResult(V, l3DecoderIndex_f, &parser_result))
    DIAG_INFO_UINT32(pos, "l4-decoder-index", GetParserResult(V, l4DecoderIndex_f, &parser_result))
    return CTC_E_NONE;
}


STATIC char*
_sys_tmm_diag_get_igr_scl_key_desc(uint8 lchip, uint32 key_type, uint8 lk_level)
{
    lk_level = !lk_level;
    if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_DISABLE))
    {
        return "";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_DOUBLEVLANPORT))
    {
        return lk_level ? "DsUserIdDoubleVlanPortHashKey" :"DsUserId1DoubleVlanPortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_SVLANPORT))
    {
        return lk_level ? "DsUserIdSvlanPortHashKey" : "DsUserId1SvlanPortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_CVLANPORT))
    {
        return lk_level ? "DsUserIdCvlanPortHashKey" : "DsUserId1CvlanPortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_SVLANCOSPORT))
    {
        return lk_level ? "DsUserIdSvlanCosPortHashKey" : "DsUserId1SvlanCosPortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_CVLANCOSPORT))
    {
        return lk_level ? "DsUserIdCvlanCosPortHashKey" : "DsUserId1CvlanCosPortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_MACPORT))
    {
        return lk_level ? "DsUserIdMacPortHashKey" : "DsUserId1MacPortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_IPV4PORT))
    {
        return lk_level ? "DsUserIdIpv4PortHashKey" : "DsUserId1Ipv4PortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_MAC))
    {
        return lk_level ? "DsUserIdMacHashKey" : "DsUserId1MacHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_IPV4SA))
    {
        return lk_level ? "DsUserIdIpv4SaHashKey" : "DsUserId1Ipv4SaHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_PORT))
    {
        return lk_level ? "DsUserIdPortHashKey" : "DsUserId1PortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_SVLANMACSA))
    {
        return lk_level ? "DsUserIdSvlanMacSaHashKey" : "DsUserId1SvlanMacSaHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_SVLAN))
    {
        return lk_level ? "DsUserIdSvlanHashKey" : "DsUserId1SvlanHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_ECIDNAMESPACE))
    {
        return lk_level ? "DsUserIdEcidNameSpaceHashKey" : "DsUserId1EcidNameSpaceHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_INGECIDNAMESPACE))
    {
        return lk_level ? "DsUserIdIngEcidNameSpaceHashKey" : "DsUserId1IngEcidNameSpaceHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_IPV6SA))
    {
        return lk_level ? "DsUserIdIpv6SaHashKey" : "DsUserId1Ipv6SaHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_IPV6PORT))
    {
        return lk_level ? "DsUserIdIpv6PortHashKey" : "DsUserId1Ipv6PortHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4))
    {
        return lk_level ? "DsUserIdTunnelIpv4HashKey" : "DsUserId1TunnelIpv4HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4GREKEY))
    {
        return lk_level ? "DsUserIdTunnelIpv4GreKeyHashKey" : "DsUserId1TunnelIpv4GreKeyHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4UDP))
    {
        return lk_level ? "DsUserIdTunnelIpv4UdpHashKey" : "DsUserId1TunnelIpv4UdpHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELTRILLUCRPF))
    {
        return lk_level ? "DsUserIdTunnelTrillUcRpfHashKey" : "DsUserId1TunnelTrillUcRpfHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELTRILLUCDECAP))
    {
        return lk_level ? "DsUserIdTunnelTrillUcDecapHashKey" : "DsUserId1TunnelTrillUcDecapHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELTRILLMCRPF))
    {
        return lk_level ? "DsUserIdTunnelTrillMcRpfHashKey" : "DsUserId1TunnelTrillMcRpfHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELTRILLMCDECAP))
    {
        return lk_level ? "DsUserIdTunnelTrillMcDecapHashKey" : "DsUserId1TunnelTrillMcDecapHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELTRILLMCADJ))
    {
        return lk_level ? "DsUserIdTunnelTrillMcAdjHashKey" : "DsUserId1TunnelTrillMcAdjHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4RPF))
    {
        return lk_level ? "DsUserIdTunnelIpv4RpfHashKey" : "DsUserId1TunnelIpv4RpfHashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4UCVXLANMODE0))
    {
        return lk_level ? "DsUserIdTunnelIpv4UcVxlanMode0HashKey" : "DsUserId1TunnelIpv4UcVxlanMode0HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4UCVXLANMODE1))
    {
        return lk_level ? "DsUserIdTunnelIpv4UcVxlanMode1HashKey" : "DsUserId1TunnelIpv4UcVxlanMode1HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6UCVXLANMODE0))
    {
        return lk_level ? "DsUserIdTunnelIpv6UcVxlanMode0HashKey" : "DsUserId1TunnelIpv6UcVxlanMode0HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6UCVXLANMODE1))
    {
        return lk_level ? "DsUserIdTunnelIpv6UcVxlanMode1HashKey" : "DsUserId1TunnelIpv6UcVxlanMode1HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4UCNVGREMODE0))
    {
        return lk_level ? "DsUserIdTunnelIpv4UcNvgreMode0HashKey" : "DsUserId1TunnelIpv4UcNvgreMode0HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4UCNVGREMODE1))
    {
        return lk_level ? "DsUserIdTunnelIpv4UcNvgreMode1HashKey" : "DsUserId1TunnelIpv4UcNvgreMode1HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6UCNVGREMODE0))
    {
        return lk_level ? "DsUserIdTunnelIpv6UcNvgreMode0HashKey" : "DsUserId1TunnelIpv6UcNvgreMode0HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6UCNVGREMODE1))
    {
        return lk_level ? "DsUserIdTunnelIpv6UcNvgreMode1HashKey" : "DsUserId1TunnelIpv6UcNvgreMode1HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4MCVXLANMODE0))
    {
        return lk_level ? "DsUserIdTunnelIpv4McVxlanMode0HashKey" : "DsUserId1TunnelIpv4McVxlanMode0HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4VXLANMODE1))
    {
        return lk_level ? "DsUserIdTunnelIpv4VxlanMode1HashKey" : "DsUserId1TunnelIpv4VxlanMode1HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6MCVXLANMODE0))
    {
        return lk_level ? "DsUserIdTunnelIpv6McVxlanMode0HashKey" : "DsUserId1TunnelIpv6McVxlanMode0HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6MCVXLANMODE1))
    {
        return lk_level ? "DsUserIdTunnelIpv6McVxlanMode1HashKey" : "DsUserId1TunnelIpv6McVxlanMode1HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4MCNVGREMODE0))
    {
        return lk_level ? "DsUserIdTunnelIpv4McNvgreMode0HashKey" : "DsUserId1TunnelIpv4McNvgreMode0HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4NVGREMODE1))
    {
        return lk_level ? "DsUserIdTunnelIpv4NvgreMode1HashKey" : "DsUserId1TunnelIpv4NvgreMode1HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6MCNVGREMODE0))
    {
        return lk_level ? "DsUserIdTunnelIpv6McNvgreMode0HashKey" : "DsUserId1TunnelIpv6McNvgreMode0HashKey";
    }
    else if(key_type ==  DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6MCNVGREMODE1))
    {
        return lk_level ? "DsUserIdTunnelIpv6McNvgreMode1HashKey" : "DsUserId1TunnelIpv6McNvgreMode1HashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4DA))
    {
        return lk_level ? "DsUserIdTunnelIpv4DaHashKey" : "DsUserId1TunnelIpv4DaHashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_SCLFLOWL2))
    {
        return lk_level ? "DsUserIdSclFlowL2HashKey" :"DsUserId1SclFlowL2HashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_IPV4DA))
    {
        return lk_level ? "DsUserId0Ipv4DaHashKey" :"DsUserId1Ipv4DaHashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_IPV6DA))
    {
        return lk_level ? "DsUserId0Ipv6DaHashKey" :"DsUserId1Ipv6DaHashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_VLANDSCPPORT))
    {
        return lk_level ? "DsUserId0VlanPortDscpHashKey" :"DsUserId1VlanPortDscpHashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6))
    {
        return lk_level ? "DsUserIdTunnelIpv6HashKey" : "DsUserId1TunnelIpv6HashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4CLOUDSEC))
    {
        return lk_level ? "DsUserId0TunnelIpv4CloudSecHashKey" : "DsUserId1TunnelIpv4CloudSecHashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6CLOUDSEC))
    {
        return lk_level ? "DsUserId0TunnelIpv6CloudSecHashKey" : "DsUserId1TunnelIpv6CloudSecHashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_SCLFLOWL2UDF))
    {
        return lk_level ? "DsUserIdSclFlowL2UDFHashKey" :"DsUserId1SclFlowL2UDFHashKey";
    }
    else if(key_type == DRV_ENUM(DRV_USERIDHASHTYPE_SCLFLOWL3UDF))
    {
        return lk_level ? "DsUserIdSclFlowL3UDFHashKey" :"DsUserId1SclFlowL3UDFHashKey";
    }
    return "";
}


STATIC int32
_sys_tmm_diag_map_tcam_key_index(uint8 lchip, uint32 dbg_index, uint8 is_acl, uint8 lkup_level, uint32* o_key_index)
{
    uint32 key_index = 0xFFFFFFFF;

    key_index = dbg_index & 0x7FF;

    if(o_key_index)
    {
        *o_key_index = key_index;
    }

    return CTC_E_NONE;
}


STATIC int32
_sys_tmm_diag_pkt_trace_get_ipe_scl_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint32 value1 = 0;
    char   str[64] = {0};
    uint8  pos = CTC_DIAG_TRACE_POS_IPE;
    uint8  is_tunnel = 0;
    uint16 lport = 0;
    uint32 hash0_keyType = 0;
    uint32 hash1_keyType = 0;
    uint8  hash0_valid = 0, hash1_valid = 0;
    uint8  tcam0_valid = 0, tcam1_valid = 0;
    //uint8  tcam_key_valid = 0;
    uint8  decode_print_valid = 0;
    //uint8  tcam_key_hit[2] = {0};
    uint8  buf_cnt[4] = {0};
    uint32 data[4] = {0};
    uint32 data_temp[4] = {0};
    uint32 ad_ds_type[4] = {0};
    uint32 ad_proc_valid[4] = {0};
    uint32 scl_userIdTcamEn[4] = {0};
    uint32 scl_userIdTcamType[4] = {0};
    char *sys_diag_l2_type[] = {"", "ETHV2", "ETHSAP", "ETHSNAP"};
    char *sys_diag_l3_type[] = {
        "",       "IP",       "IPV4",         "IPV6",
        "MPLS",   "MPLSUP",   "ARP",          "FCOE",
        "TRILL",  "ETHEROAM", "SLOWPROTO",    "RESERVED",
        "PTP",    "DOT1AE",   "SATPDU",       "FLEXIBLE"};
    char *sys_diag_l4_type[] = {
        "NONE",   "TCP",      "GRE",      "UDP",
        "IPINIP", "V6INIP",   "ICMP",     "IGMP",
        "IPINV6", "RESERVED", "ACHOAM",   "V6INV6",
        "RDP",    "SCTP",     "DCCP",     "FLEXIBLE"};
    char *sys_diag_l4_user_type_achoam[] = {
        "",          "ACHY1731", "ACHBFD",   "ACHCC",
        "ACHCV",     "ACHDLM",   "ACHILM",   "ACHILMDM",
        "ACHDLMDM",  "ACHDM",    "MCC",      "SCC"};
    char *sys_diag_l4_user_type_gre[] = {"", "GRE_C", "GRE_K", "GRE_C_K"};
    char *sys_diag_l4_user_type_tcp[] = {"", "TCPINT", "TCPINTPROBE"};
    char *sys_diag_l4_user_type_udp[] = {
        "",     "BFD",          "UDPPTP",       "RESERVED0",
        "NTP",  "RESERVED1",    "RESERVED2",    "RESERVED3",
        "VXLAN"};
    char* str_scl_key_type[] = {
            "RESERVED0",    "L3KEY160",     "IPV6KEY320",   "MACL3KEY320",
            "UDFKEY320",    "UDFKEY640",    "UDFKEY160",    "MACIPV6KEY640",
            "PKTL2",        "PKTL3L4",      "RESERVED_3",   "MACKEY160",
            "RESERVED_4",   "RESERVED_5",   "RESERVED_6",   "INVALID"
        };
    const char *svlan_type[] = {"default-svlan-id", "pkt-svlan-id"};
    const char *cvlan_type[] = {"default-cvlan-id", "pkt-cvlan-id"};
    char* str_ad_ds_type[] = {"USERID","TUNNELID"};
    uint32 scl_key_size = 1;
    uint32 tcam_userIdTcamIndex[4] = {0};
    uint32 tcam_userIdValid[4] = {0};
    DbgIpeUserIdInfo_m user_id;
    DbgUserIdHashEngineForUserId0Info_m user_id0;
    DbgUserIdHashEngineForUserId1Info_m user_id1;
    DbgUserIdTcamEngineForUserId0Info_m scl_tcam0;
    DbgUserIdTcamEngineForUserId1Info_m scl_tcam1;
    //DbgSclTcamEngineInfo_m tcam_engine;
    union
    {
        DbgSCLEngineDecoderSclInputInfo_m decoder_info;
        DbgSCLEngineUdfDecoderInfo_m udf_decoder;
        DbgSCLEngineL2DecoderInfo_m l2_decoder;
        DbgSCLEngineL3DecoderInfo_m l3_decoder;
        DbgSCLEngineL4DecoderInfo_m l4_decoder;
    } un;
    void *ds = (void*)&un.decoder_info;

    sal_memset(&user_id, 0, sizeof(user_id));
    cmd = DRV_IOR(DbgIpeUserIdInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &user_id));

    if (!GetDbgIpeUserIdInfo(V, valid_f, &user_id) || !GetDbgIpeUserIdInfo(V, userIdEn_f, &user_id))
    {
        return CTC_E_NONE;
    }

    /*DbgUserIdHashEngineForUserId0Info*/
    sal_memset(&user_id0, 0, sizeof(user_id0));
    cmd = DRV_IOR(DbgUserIdHashEngineForUserId0Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &user_id0));

    /*DbgUserIdHashEngineForUserId1Info*/
    sal_memset(&user_id1, 0, sizeof(user_id1));
    cmd = DRV_IOR(DbgUserIdHashEngineForUserId1Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &user_id1));

    cmd = DRV_IOR(DbgUserIdTcamEngineForUserId0Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &scl_tcam0));
    cmd = DRV_IOR(DbgUserIdTcamEngineForUserId1Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &scl_tcam1));
    //cmd = DRV_IOR(DbgSclTcamEngineInfo_t, DRV_ENTRY_FLAG);
    //CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &tcam_engine));

    lport = GetDbgIpeUserIdInfo(V, localPhyPort_f, &user_id);
    hash0_valid = GetDbgUserIdHashEngineForUserId0Info(V, valid_f, &user_id0);
    hash0_keyType = GetDbgUserIdHashEngineForUserId0Info(V, userIdKeyType_f, &user_id0);
    hash1_valid = GetDbgUserIdHashEngineForUserId1Info(V, valid_f, &user_id1);
    hash1_keyType =GetDbgUserIdHashEngineForUserId1Info(V, userIdKeyType_f, &user_id1);
    scl_userIdTcamEn[0] = hash0_valid && hash0_keyType;
    scl_userIdTcamEn[1] = hash1_valid && hash1_keyType;
    tcam0_valid = GetDbgUserIdTcamEngineForUserId0Info(V, valid_f, &scl_tcam0);
    tcam1_valid = GetDbgUserIdTcamEngineForUserId1Info(V, valid_f, &scl_tcam1);
    scl_userIdTcamEn[2] = tcam0_valid && GetDbgUserIdTcamEngineForUserId0Info(V, lookupEnable_f, &scl_tcam0);
    scl_userIdTcamEn[3] = tcam1_valid && GetDbgUserIdTcamEngineForUserId1Info(V, lookupEnable_f, &scl_tcam1);

    if (!(scl_userIdTcamEn[0] || scl_userIdTcamEn[1] || scl_userIdTcamEn[2] || scl_userIdTcamEn[3]))
    {
        return CTC_E_NONE;
    }

    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "SCL")

    ad_ds_type[0] = GetDbgIpeUserIdInfo(V, process0AdDsType_f, &user_id);
    ad_ds_type[1] = GetDbgIpeUserIdInfo(V, process1AdDsType_f, &user_id);
    ad_ds_type[2] = GetDbgIpeUserIdInfo(V, process2AdDsType_f, &user_id);
    ad_ds_type[3] = GetDbgIpeUserIdInfo(V, process3AdDsType_f, &user_id);
    ad_proc_valid[0] = GetDbgIpeUserIdInfo(V, adProcessValid0_f, &user_id);
    ad_proc_valid[1] = GetDbgIpeUserIdInfo(V, adProcessValid1_f, &user_id);
    ad_proc_valid[2] = GetDbgIpeUserIdInfo(V, adProcessValid2_f, &user_id);
    ad_proc_valid[3] = GetDbgIpeUserIdInfo(V, adProcessValid3_f, &user_id);

    decode_print_valid = (scl_userIdTcamEn[0] && GetDbgUserIdHashEngineForUserId0Info(V, lookupResultValid_f, &user_id0)) ||
                         (scl_userIdTcamEn[1] && GetDbgUserIdHashEngineForUserId1Info(V, lookupResultValid_f, &user_id1)) ||
                         (scl_userIdTcamEn[2] && GetDbgUserIdTcamEngineForUserId0Info(V, lookupResultValid_f, &scl_tcam0)) ||
                         (scl_userIdTcamEn[3] && GetDbgUserIdTcamEngineForUserId1Info(V, lookupResultValid_f, &scl_tcam1));
    cmd = DRV_IOR(DbgSCLEngineDecoderSclInputInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, ds));
    if (GetDbgSCLEngineDecoderSclInputInfo(V, valid_f, ds) && decode_print_valid)
    {
        DIAG_INFO_NONE(pos, "--SCL Decoder Info")
        DIAG_INFO_UINT32(pos, "global-port", SYS_MAP_DRV_GPORT_TO_CTC_GPORT(GetDbgSCLEngineDecoderSclInputInfo(V, globalSrcPort_f, ds)))
        DIAG_INFO_UINT32(pos, "local-port", GetDbgSCLEngineDecoderSclInputInfo(V, localPhyPort_f, ds))
        DIAG_INFO_UINT32(pos, "logic-port", GetDbgSCLEngineDecoderSclInputInfo(V, logicSrcPort_f, ds))
        DIAG_INFO_UINT32(pos, "udf-hit-index", GetDbgSCLEngineDecoderSclInputInfo(V, udfHitIndex_f, ds))
        DIAG_INFO_UINT32(pos, "vlan-num", GetDbgSCLEngineDecoderSclInputInfo(V, vlanNum_f, ds))
        if (GetDbgSCLEngineDecoderSclInputInfo(V, userIdVlanRangeValid_f, ds))
        {
            DIAG_INFO_CHAR(pos, "vlan-range-type", GetDbgSCLEngineDecoderSclInputInfo(V, vlanRangeType_f, ds) ? "svlan" : "cvlan")
            DIAG_INFO_UINT32(pos, "vlan-range-max", GetDbgSCLEngineDecoderSclInputInfo(V, userIdVlanRangeMax_f, ds))
        }
        if (GetDbgSCLEngineDecoderSclInputInfo(V, tempSvlanIdValid_f, ds))
        {
            DIAG_INFO_UINT32(pos,STR_ARRAY(svlan_type,GetDbgSCLEngineDecoderSclInputInfo(V, svlanIdValid_f, ds)), GetDbgSCLEngineDecoderSclInputInfo(V, tempSvlanId_f, ds))
            DIAG_INFO_UINT32(pos, "stag-cos", GetDbgSCLEngineDecoderSclInputInfo(V, stagCos_f, ds))
            DIAG_INFO_UINT32(pos, "stag-cfi", GetDbgSCLEngineDecoderSclInputInfo(V, stagCfi_f, ds))
        }
        if (GetDbgSCLEngineDecoderSclInputInfo(V, tempCvlanIdValid_f, ds))
        {
            DIAG_INFO_UINT32(pos,STR_ARRAY(cvlan_type,GetDbgSCLEngineDecoderSclInputInfo(V, cvlanIdValid_f, ds)), GetDbgSCLEngineDecoderSclInputInfo(V, tempCvlanId_f, ds))
            DIAG_INFO_UINT32(pos, "ctag-cos", GetDbgSCLEngineDecoderSclInputInfo(V, ctagCos_f, ds))
            DIAG_INFO_UINT32(pos, "ctag-cfi", GetDbgSCLEngineDecoderSclInputInfo(V, ctagCfi_f, ds))
        }
        DIAG_INFO_CHAR(pos, "l2-type",STR_ARRAY(sys_diag_l2_type,GetDbgSCLEngineDecoderSclInputInfo(V, layer2Type_f, ds)))
        DIAG_INFO_UINT32(pos, "l2-decode-index", GetDbgSCLEngineDecoderSclInputInfo(V, l2DecoderIndex_f, ds))
        value = GetDbgSCLEngineDecoderSclInputInfo(V, layer3Type_f, ds);
        DIAG_INFO_CHAR(pos, "l3-type",STR_ARRAY(sys_diag_l3_type,value))
        DIAG_INFO_UINT32(pos, "l3-offset", GetDbgSCLEngineDecoderSclInputInfo(V, layer3Offset_f, ds))
        DIAG_INFO_UINT32(pos, "l3-decode-index", GetDbgSCLEngineDecoderSclInputInfo(V, l3DecoderIndex_f, ds))
        DIAG_INFO_UINT32(pos, "frag-info", GetDbgSCLEngineDecoderSclInputInfo(V, fragInfo_f, ds))
        DIAG_INFO_UINT32(pos, "ip-options", GetDbgSCLEngineDecoderSclInputInfo(V, ipOptions_f, ds))
        DIAG_INFO_UINT32(pos, "ip-pkt-len-range-id", GetDbgSCLEngineDecoderSclInputInfo(V, ipPktLenRangeId_f, ds))
        DIAG_INFO_UINT32(pos, "ip-hdr-error", GetDbgSCLEngineDecoderSclInputInfo(V, ipHeaderError_f, ds))
        if ((value == DIAG_L3TYPE_MPLS) || (value == DIAG_L3TYPE_MPLSUP))
        {
            DIAG_INFO_UINT32(pos, "label-num", GetDbgSCLEngineDecoderSclInputInfo(V, labelNum_f, ds))
        }
        value = GetDbgSCLEngineDecoderSclInputInfo(V, layer4Type_f, ds);
        DIAG_INFO_CHAR(pos, "l4-type", STR_ARRAY(sys_diag_l4_type,value))
        DIAG_INFO_UINT32(pos, "l4-offset", GetDbgSCLEngineDecoderSclInputInfo(V, layer4Offset_f, ds))
        DIAG_INFO_UINT32(pos, "l4-decode-index", GetDbgSCLEngineDecoderSclInputInfo(V, l4DecoderIndex_f, ds))
        value1 = GetDbgSCLEngineDecoderSclInputInfo(V, layer4UserType_f, ds);
        switch(value)
        {
            case DIAG_L4TYPE_TCP:
                DIAG_INFO_CHAR(pos, "l4-user-type", STR_ARRAY(sys_diag_l4_user_type_tcp,value1))
                break;
            case DIAG_L4TYPE_UDP:
                DIAG_INFO_CHAR(pos, "l4-user-type", STR_ARRAY(sys_diag_l4_user_type_udp,value1))
                break;
            case DIAG_L4TYPE_GRE:
                DIAG_INFO_CHAR(pos, "l4-user-type", STR_ARRAY(sys_diag_l4_user_type_gre,value1))
                break;
            case DIAG_L4TYPE_ACHOAM:
                DIAG_INFO_CHAR(pos, "l4-user-type", STR_ARRAY(sys_diag_l4_user_type_achoam,value1))
                break;
            default:
                DIAG_INFO_UINT32(pos, "l4-user-type", value)
                break;
        }
        if (GetDbgSCLEngineDecoderSclInputInfo(V, customerIdValid_f, ds))
        {
            DIAG_INFO_UINT32(pos, "customer-id", GetDbgSCLEngineDecoderSclInputInfo(V, customerId_f, ds))
        }
        DIAG_INFO_UINT32(pos, "parser-len", GetDbgSCLEngineDecoderSclInputInfo(V, parserLength_f, ds))
        DIAG_INFO_UINT32(pos, "mux-destination", GetDbgSCLEngineDecoderSclInputInfo(V, muxDestination_f, ds))
        DIAG_INFO_UINT32(pos, "tcp-data-offset", GetDbgSCLEngineDecoderSclInputInfo(V, tcpDataOffset_f, ds))
        DIAG_INFO_U32_HEX(pos, "l4-port-range-bimap", GetDbgSCLEngineDecoderSclInputInfo(V, l4PortRangeBitmap_f, ds))
        DIAG_INFO_UINT32(pos, "ecid", GetDbgSCLEngineDecoderSclInputInfo(V, ecid_f, ds))
        DIAG_INFO_UINT32(pos, "name-space", GetDbgSCLEngineDecoderSclInputInfo(V, ecidNameSpace_f, ds))
        DIAG_INFO_UINT32(pos, "is-vxlan", GetDbgSCLEngineDecoderSclInputInfo(V, isVxlan_f, ds))
        DIAG_INFO_UINT32(pos, "is-cloud-sec", GetDbgSCLEngineDecoderSclInputInfo(V, isCloudSec_f, ds))
        DIAG_INFO_UINT32(pos, "hmac-check-en", GetDbgSCLEngineDecoderSclInputInfo(V, hmacCheckEn_f, ds))
    }
    cmd = DRV_IOR(DbgSCLEngineUdfDecoderInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, ds));
    if (GetDbgSCLEngineUdfDecoderInfo(V, valid_f, ds))
    {
        DIAG_INFO_NONE(pos, "--SCL UDF Decoder")
        switch(GetDbgSCLEngineUdfDecoderInfo(V, fibKeyUdfSelType_f, ds))
        {
            case 1:
            {
                DIAG_INFO_CHAR(pos, "fib-ipv6-da use", "UDF")
                break;
            }
            case 2:
            {
                DIAG_INFO_CHAR(pos, "fib-mac-da use", "UDF")
                break;
            }
            case 3:
            {
                DIAG_INFO_CHAR(pos, "fib-mac-sa use", "UDF")
                break;
            }
            case 0:
            default:
                break;
        }
        if (GetDbgSCLEngineUdfDecoderInfo(V, udfValid_f, ds))
        {
            uint16 udf_ad_id = GetDbgSCLEngineUdfDecoderInfo(V, udfHitIndex_f, ds);
            sys_acl_udf_info_t udf_info = {0};
            DIAG_INFO_CHAR(pos, "udf-lkup", DIAG_LOOKUP_HIT)
            DIAG_INFO_UINT32(pos, "udf-hit-index", udf_ad_id)
            GetDbgSCLEngineUdfDecoderInfo(A, udf_f, ds, data);

            sys_usw_acl_get_udf_info_by_ad_id(lchip, udf_ad_id, &udf_info);

            DIAG_SET_USR_UDF(udf_info.granularity, data_temp,data);
            DIAG_INFO_UDF(pos, "udf-data", data_temp);
        }
        else
        {
            DIAG_INFO_CHAR(pos, "udf-lkup", DIAG_LOOKUP_HIT_NONE)
        }
    }
    cmd = DRV_IOR(DbgSCLEngineL2DecoderInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, ds));
    if (GetDbgSCLEngineL2DecoderInfo(V, valid_f, ds) && decode_print_valid)
    {
        DIAG_INFO_NONE(pos, "--SCL L2 Decoder")
        GetDbgSCLEngineL2DecoderInfo(A, macDa_f, ds, data);
        DIAG_INFO_MAC(pos, "mac-da", data)
        GetDbgSCLEngineL2DecoderInfo(A, macSa_f, ds, data);
        DIAG_INFO_MAC(pos, "mac-sa", data)
        DIAG_INFO_UINT32(pos, "ether-type", GetDbgSCLEngineL2DecoderInfo(V, etherType_f, ds))
        DIAG_INFO_UINT32(pos, "svlan-id", GetDbgSCLEngineL2DecoderInfo(V, svlanTag_f, ds))
        DIAG_INFO_UINT32(pos, "cvlan-id", GetDbgSCLEngineL2DecoderInfo(V, cvlanTag_f, ds))
        DIAG_INFO_U32_HEX(pos, "data0", GetDbgSCLEngineL2DecoderInfo(V, data0_f, ds))
        DIAG_INFO_U32_HEX(pos, "data1", GetDbgSCLEngineL2DecoderInfo(V, data1_f, ds))
    }
    cmd = DRV_IOR(DbgSCLEngineL3DecoderInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, ds));
    if (GetDbgSCLEngineL3DecoderInfo(V, valid_f, ds) && decode_print_valid)
    {
        DIAG_INFO_NONE(pos, "--SCL L3 Decoder")
        DIAG_INFO_U32_HEX(pos, "data0", GetDbgSCLEngineL3DecoderInfo(V, uF0_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data1", GetDbgSCLEngineL3DecoderInfo(V, uF1_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data2", GetDbgSCLEngineL3DecoderInfo(V, uF2_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data3", GetDbgSCLEngineL3DecoderInfo(V, uF3_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data4", GetDbgSCLEngineL3DecoderInfo(V, uF4_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data5", GetDbgSCLEngineL3DecoderInfo(V, uF5_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data6", GetDbgSCLEngineL3DecoderInfo(V, uF6_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data7", GetDbgSCLEngineL3DecoderInfo(V, uF7_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data8", GetDbgSCLEngineL3DecoderInfo(V, uF8_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data9", GetDbgSCLEngineL3DecoderInfo(V, uF9_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data10", GetDbgSCLEngineL3DecoderInfo(V, uF10_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data11", GetDbgSCLEngineL3DecoderInfo(V, uF11_gField_data_f, ds))
    }
    cmd = DRV_IOR(DbgSCLEngineL4DecoderInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, ds));
    if (GetDbgSCLEngineL4DecoderInfo(V, valid_f, ds) && decode_print_valid)
    {
        DIAG_INFO_NONE(pos, "--SCL L4 Decoder")
        DIAG_INFO_U32_HEX(pos, "data0", GetDbgSCLEngineL4DecoderInfo(V, uF0_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data1", GetDbgSCLEngineL4DecoderInfo(V, uF1_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data2", GetDbgSCLEngineL4DecoderInfo(V, uF2_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data3", GetDbgSCLEngineL4DecoderInfo(V, uF3_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data4", GetDbgSCLEngineL4DecoderInfo(V, uF4_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "data5", GetDbgSCLEngineL4DecoderInfo(V, uF5_gField_data_f, ds))
    }

    cmd = DRV_IOR(DsPhyPortExt_t, DsPhyPortExt_userIdResultPriorityMode_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, lport, cmd, &value));
    switch (value)
    {
        case 0:
            buf_cnt[0] = 0;
            buf_cnt[1] = 1;
            buf_cnt[2] = 2;
            buf_cnt[3] = 3;
            break;
        case 1:
            buf_cnt[2] = 0;
            buf_cnt[0] = 1;
            buf_cnt[1] = 2;
            buf_cnt[3] = 3;
            break;
        case 2:
            buf_cnt[2] = 0;
            buf_cnt[3] = 1;
            buf_cnt[0] = 2;
            buf_cnt[1] = 3;
            break;
        case 3:
            buf_cnt[0] = 0;
            buf_cnt[2] = 1;
            buf_cnt[1] = 2;
            buf_cnt[3] = 3;
            break;
        case 4:
            buf_cnt[2] = 0;
            buf_cnt[0] = 1;
            buf_cnt[3] = 2;
            buf_cnt[1] = 3;
            break;
        default:
            break;
    }

    DIAG_INFO_NONE(pos, "--SCL Lookup Info")
    for (value = 0; value < 4; value++)
    {
        if (ad_proc_valid[buf_cnt[value]])
        {
            sal_sprintf(str, "ad-type-%d", value);
            DIAG_INFO_CHAR(pos, str, STR_ARRAY(str_ad_ds_type,ad_ds_type[buf_cnt[value]]))
        }
    }

    if (GetDbgIpeUserIdInfo(V, routerMacHit_f, &user_id))
    {
        value = GetDbgIpeUserIdInfo(V, isRouterMac_f, &user_id);
        if (GetDbgIpeUserIdInfo(V, routerMacLookupEn_f, &user_id))
        {
            DIAG_INFO_CHAR(pos, "Route-MAC-Tcam", value? DIAG_LOOKUP_HIT: DIAG_LOOKUP_HIT_NONE)
        }
        else
        {
            DIAG_INFO_CHAR(pos, "SCL-Hit-Route-MAC", value? DIAG_LOOKUP_HIT: DIAG_LOOKUP_HIT_NONE)
        }
    }

    /*hash0*/
    if (hash0_keyType && hash0_valid)
    {
        value = GetDbgUserIdHashEngineForUserId0Info(V, keyIndex_f, &user_id0);
        value1 = GetDbgUserIdHashEngineForUserId0Info(V, debugAdIndex_f, &user_id0);
        if (GetDbgUserIdHashEngineForUserId0Info(V, debugTcamResultValid_f, &user_id0) || GetDbgUserIdHashEngineForUserId0Info(V, hashConflict_f, &user_id0))
        {
            DIAG_INFO_CHAR(pos, "hash-0-lookup-result", DIAG_LOOKUP_CONFLICT)
            DIAG_INFO_UINT32(pos, "key-index", value)
            DIAG_INFO_CHAR(pos, "key-name", _sys_tmm_diag_get_igr_scl_key_desc(lchip, hash0_keyType, 0))
        }
        else if (GetDbgUserIdHashEngineForUserId0Info(V, defaultEntryValid_f, &user_id0))
        {
            DIAG_INFO_CHAR(pos, "hash-0-lookup-result", DIAG_LOOKUP_DEFAULT)
        }
        else if (GetDbgUserIdHashEngineForUserId0Info(V, lookupResultValid_f, &user_id0))
        {
            DIAG_INFO_CHAR(pos, "hash-0-lookup-result", DIAG_LOOKUP_HIT)
        }
        else
        {
            DIAG_INFO_CHAR(pos, "hash-0-lookup-result", DIAG_LOOKUP_HIT_NONE)
        }
        is_tunnel = (hash0_keyType >= DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4)) && (hash0_keyType < DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6CLOUDSEC));
        if (GetDbgUserIdHashEngineForUserId0Info(V, defaultEntryValid_f, &user_id0)
            || GetDbgUserIdHashEngineForUserId0Info(V, lookupResultValid_f, &user_id0))
        {
            DIAG_INFO_UINT32(pos, "key-index", value)
            DIAG_INFO_CHAR(pos, "key-name", _sys_tmm_diag_get_igr_scl_key_desc(lchip, hash0_keyType, 0))
            DIAG_INFO_UINT32(pos, "ad-index", value1)

            if (hash0_keyType && !is_tunnel)
            {
                cmd = DRV_IOR(DsUserIdHalf_t, DsUserIdHalf_isHalf_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, value1, cmd, &value));
                if (value)
                {
                    DIAG_INFO_CHAR(pos, "ad-name", "DsUserIdHalf")
                }
                else
                {
                    DIAG_INFO_CHAR(pos, "ad-name", "DsUserId")
                }
            }
            else if (hash0_keyType)
            {
                cmd = DRV_IOR(DsTunnelIdHalf_t, DsTunnelIdHalf_isHalf_f);
                DRV_FIELD_IOCTL(lchip, value1, cmd, &value);
                if (value)
                {
                    DIAG_INFO_CHAR(pos, "ad-name", "DsTunnelIdHalf")
                }
                else
                {
                    DIAG_INFO_CHAR(pos, "ad-name", "DsTunnelId")
                }
            }
        }
    }

    /*hash1*/
    if (hash1_keyType && hash1_valid)
    {
        value = GetDbgUserIdHashEngineForUserId1Info(V, keyIndex_f, &user_id1);
        value1 = GetDbgUserIdHashEngineForUserId1Info(V, debugAdIndex_f, &user_id1);
        if (GetDbgUserIdHashEngineForUserId1Info(V, debugTcamResultValid_f, &user_id1) || GetDbgUserIdHashEngineForUserId1Info(V, hashConflict_f, &user_id1))
        {
            DIAG_INFO_CHAR(pos, "hash-1-lookup-result",  DIAG_LOOKUP_CONFLICT)
            DIAG_INFO_UINT32(pos, "key-index", value)
            DIAG_INFO_CHAR(pos, "key-name", _sys_tmm_diag_get_igr_scl_key_desc(lchip, hash1_keyType, 1))
        }
        else if (GetDbgUserIdHashEngineForUserId1Info(V, defaultEntryValid_f, &user_id1))
        {
            DIAG_INFO_CHAR(pos, "hash-1-lookup-result", DIAG_LOOKUP_DEFAULT)
        }
        else if (GetDbgUserIdHashEngineForUserId1Info(V, lookupResultValid_f, &user_id1))
        {
            DIAG_INFO_CHAR(pos, "hash-1-lookup-result", DIAG_LOOKUP_HIT)
        }
        else
        {
            DIAG_INFO_CHAR(pos, "hash-1-lookup-result", DIAG_LOOKUP_HIT_NONE)
        }
        is_tunnel = (hash1_keyType >= DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV4)) && (hash1_keyType < DRV_ENUM(DRV_USERIDHASHTYPE_TUNNELIPV6CLOUDSEC));
        if (GetDbgUserIdHashEngineForUserId1Info(V, defaultEntryValid_f, &user_id1)
            || GetDbgUserIdHashEngineForUserId1Info(V, lookupResultValid_f, &user_id1))
        {
            DIAG_INFO_UINT32(pos, "key-index", value)
            DIAG_INFO_CHAR(pos, "key-name", _sys_tmm_diag_get_igr_scl_key_desc(lchip, hash1_keyType, 1))
            DIAG_INFO_UINT32(pos, "ad-index", value1)
            if (hash1_keyType && !is_tunnel)
            {
                cmd = DRV_IOR(DsUserIdHalf1_t, DsUserIdHalf1_isHalf_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, value1, cmd, &value));
                if (value)
                {
                    DIAG_INFO_CHAR(pos, "ad-name", "DsUserIdHalf1")
                }
                else
                {
                    DIAG_INFO_CHAR(pos, "ad-name", "DsUserId1")
                }
            }
            else if (hash1_keyType)
            {
                cmd = DRV_IOR(DsTunnelIdHalf1_t, DsTunnelIdHalf1_isHalf_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, value1, cmd, &value));
                if (value)
                {
                    DIAG_INFO_CHAR(pos, "ad-name", "DsTunnelIdHalf1")
                }
                else
                {
                    DIAG_INFO_CHAR(pos, "ad-name", "DsTunnelId1")
                }
            }
        }
    }

    scl_userIdTcamType[2] = GetDbgUserIdTcamEngineForUserId0Info(V, tcamKeyType_f, &scl_tcam0);
    scl_userIdTcamType[3] = GetDbgUserIdTcamEngineForUserId1Info(V, tcamKeyType_f, &scl_tcam1);
    tcam_userIdValid[2] = GetDbgUserIdTcamEngineForUserId0Info(V, lookupResultValid_f, &scl_tcam0);
    tcam_userIdValid[3] = GetDbgUserIdTcamEngineForUserId1Info(V, lookupResultValid_f, &scl_tcam1);

    tcam_userIdTcamIndex[2] = tcam_userIdValid[2]? GetDbgUserIdTcamEngineForUserId0Info(V, debugAdIndex_f, &scl_tcam0): 0xFFFFFFFF;
    tcam_userIdTcamIndex[3] = tcam_userIdValid[3]? GetDbgUserIdTcamEngineForUserId1Info(V, debugAdIndex_f, &scl_tcam1): 0xFFFFFFFF;

    /*tcam0~3*/
/* __TODO__ spec tcam 0 and 1 not provide debug info*/
    for (value1 = 2; value1 < 4; value1++)
    {
        if (!scl_userIdTcamEn[value1])
        {
            continue;
        }
        sal_sprintf(str, "tcam-%d-lookup-result",value1);
        if (tcam_userIdValid[value1])
        {
            DIAG_INFO_CHAR(pos, str, DIAG_LOOKUP_HIT)
            DIAG_INFO_CHAR(pos, "key-type", STR_ARRAY(str_scl_key_type,scl_userIdTcamType[value1]))
            _sys_tmm_diag_map_tcam_key_index(lchip, tcam_userIdTcamIndex[value1], 0, value1, &value);
            if (value1 == 2)
            {
                scl_key_size = GetDbgUserIdTcamEngineForUserId0Info(V, keySize_f, &scl_tcam0);
            }
            else if (value1 == 3)
            {
                scl_key_size = GetDbgUserIdTcamEngineForUserId1Info(V, keySize_f, &scl_tcam1);
            }
            if(scl_key_size > 0)
            {
                DIAG_INFO_UINT32(pos, "key-index", value / (1 << (scl_key_size - 1)))
            }
            DIAG_INFO_UINT32(pos, "key-size", 80*(1<<scl_key_size))
        }
        else
        {
            DIAG_INFO_CHAR(pos, str, DIAG_LOOKUP_HIT_NONE)
        }
    }


    /* Drop Process */
    _sys_tmm_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeUserIdInfo(V, discard_f, &user_id),
                                          GetDbgIpeUserIdInfo(V, discardType_f, &user_id));



    /* Exception Process */
    _sys_tmm_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeUserIdInfo(V, exceptionEn_f, &user_id),
                                               GetDbgIpeUserIdInfo(V, exceptionIndex_f, &user_id),
                                               GetDbgIpeUserIdInfo(V, exceptionSubIndex_f, &user_id));
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_ipe_intf_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint8 gchip = 0;
    uint32 value = 0;
    uint32 value1 = 0;
    uint32 vlanPtr = 0;
    uint32 cmd = 0;
    uint32 lport = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    char* vlanId_action[] = {"NONE", "SWAP", "USER","default"};
    DbgIpeUserIdInfo_m user_id_info;
    DbgIpeIntfMapperInfo_m intf_mapper_info;


    sal_memset(&user_id_info, 0, sizeof(user_id_info));
    cmd = DRV_IOR(DbgIpeUserIdInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &user_id_info));
    sal_memset(&intf_mapper_info, 0, sizeof(intf_mapper_info));
    cmd = DRV_IOR(DbgIpeIntfMapperInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &intf_mapper_info));

    if (!GetDbgIpeIntfMapperInfo(V, valid_f, &intf_mapper_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "Interface Mapper")

    if (GetDbgIpeUserIdInfo(V, lowLatencyEn_f, &user_id_info))
    {
        DIAG_INFO_CHAR(pos, "low-lantency", "enable")
    }
    if (GetDbgIpeUserIdInfo(V, macsecProcessed_f, &user_id_info))
    {
        DIAG_INFO_CHAR(pos, "dot1ae-decrypted", GetDbgIpeUserIdInfo(V, macsecDecrypted_f, &user_id_info)? "Yes": "No")
        if (GetDbgIpeUserIdInfo(V, uncontrolledPortPkt_f, &user_id_info))
        {
            DIAG_INFO_CHAR(pos, "dot1ae-pkt", "invalid")
        }
        else if (GetDbgIpeUserIdInfo(V, uncontrolledPortSecTagPkt_f, &user_id_info))
        {
            DIAG_INFO_CHAR(pos, "dot1ae-pkt", "error")
        }
        else if (GetDbgIpeUserIdInfo(V, unsupportedSecTagPkt_f, &user_id_info))
        {
            DIAG_INFO_CHAR(pos, "dot1ae-pkt", "not support")
        }
    }

    lport = GetDbgIpeUserIdInfo(V, localPhyPort_f, &user_id_info);
    if (GetDbgIpeUserIdInfo(V, valid_f, &user_id_info))
    {
        CTC_ERROR_RETURN(drv_get_gchip_id(lchip, &gchip));
        DIAG_INFO_U32_HEX(pos, "source-port", CTC_MAP_LPORT_TO_GPORT(gchip, lport))
    }

    vlanPtr = GetDbgIpeIntfMapperInfo(V, vlanPtr_f, &intf_mapper_info);
    DIAG_INFO_UINT32(pos, "vlan-ptr", vlanPtr)

    if (GetDbgIpeIntfMapperInfo(V, svlanTagOperationValid_f, &intf_mapper_info))
    {
        value = GetDbgIpeIntfMapperInfo(V, sVlanIdAction_f, &intf_mapper_info);
        DIAG_INFO_CHAR(pos, "ingress-svlan-action", STR_ARRAY(vlanId_action,value))
        if (value)
        {
            DIAG_INFO_UINT32(pos, "new-svlan-id", GetDbgIpeIntfMapperInfo(V, svlanId_f, &intf_mapper_info))
        }
    }
    if (GetDbgIpeIntfMapperInfo(V, cvlanTagOperationValid_f, &intf_mapper_info))
    {
        value = GetDbgIpeIntfMapperInfo(V, cVlanIdAction_f, &intf_mapper_info);
        DIAG_INFO_CHAR(pos, "ingress-cvlan-action", STR_ARRAY(vlanId_action,value))
        if (value)
        {
            DIAG_INFO_UINT32(pos, "new-cvlan-id", GetDbgIpeIntfMapperInfo(V, cvlanId_f, &intf_mapper_info))
        }
    }
    value = GetDbgIpeIntfMapperInfo(V, interfaceId_f, &intf_mapper_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "l3-intf-id", value)
        cmd = DRV_IOR(DsSrcInterface_t, DsSrcInterface_vrfId_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, value, cmd, &value1));
        DIAG_INFO_UINT32(pos, "intf-vrfid", value1)
        DIAG_INFO_CHAR(pos, "vrfid-loop-en", GetDbgIpeIntfMapperInfo(V, vrfIdLoopEn_f, &intf_mapper_info)? DIAG_ENABLE : DIAG_DISABLE)
        DIAG_INFO_CHAR(pos, "route-mac", GetDbgIpeIntfMapperInfo(V, isRouterMac_f, &intf_mapper_info) ? "YES" : "NO")
    }
    cmd = DRV_IOR(DsSrcPort_t, DsSrcPort_portCrossConnect_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, lport, cmd, &value));
    if (value)
    {
        DIAG_INFO_CHAR(pos, "cross-connect", "YES")
    }
    else
    {
        /*bridge en*/
        cmd = DRV_IOR(DsSrcPort_t, DsSrcPort_bridgeEn_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, lport, cmd, &value));
        if (vlanPtr < 4096)
        {
            cmd = DRV_IOR(DsSrcVlan_t, DsSrcVlan_bridgeDisable_f);
            CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, vlanPtr, cmd, &value1));
        }
        value = value && (!value1);
        DIAG_INFO_CHAR(pos, "bridge-port", value ?"YES":"NO")

        /*route en*/
        cmd = DRV_IOR(DsSrcPort_t, DsSrcPort_routedPort_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, lport, cmd, &value));
        DIAG_INFO_CHAR(pos, "route-port", value ?"YES":"NO")
    }
    /*mpls en*/
    value = GetDbgIpeIntfMapperInfo(V, interfaceId_f, &intf_mapper_info);
    if (value)
    {
        cmd = DRV_IOR(DsSrcInterface_t, DsSrcInterface_mplsEn_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, value, cmd, &value1));
        DIAG_INFO_CHAR(pos, "mpls-port", value1 ?"YES":"NO")
    }
    if (!GetDbgIpeUserIdInfo(V, valid_f, &user_id_info))
    {
        return CTC_E_NONE;
    }
    if (GetDbgIpeUserIdInfo(V, pduTypeValid_f, &user_id_info))
    {
        DIAG_INFO_UINT32(pos, "l2-user-pdu-type", GetDbgIpeUserIdInfo(V, pduType_f, &user_id_info))
    }

    /* Drop Process */
    _sys_tmm_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeUserIdInfo(V, macsecSopDiscard_f, &user_id_info),
                                          GetDbgIpeUserIdInfo(V, macsecSopDiscardType_f, &user_id_info));
    _sys_tmm_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeIntfMapperInfo(V, discard_f, &intf_mapper_info),
                                          GetDbgIpeIntfMapperInfo(V, discardType_f, &intf_mapper_info));
    /* Exception Process */
    _sys_tmm_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeIntfMapperInfo(V, exceptionEn_f, &intf_mapper_info),
                                               GetDbgIpeIntfMapperInfo(V, exceptionIndex_f, &intf_mapper_info),
                                               GetDbgIpeIntfMapperInfo(V, exceptionSubIndex_f, &intf_mapper_info));
    return CTC_E_NONE;
}


STATIC int32
_sys_tmm_diag_pkt_trace_get_ipe_decap_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
#if (0 == SDK_WORK_PLATFORM)
    uint32 value = 0;
#endif
    char* str[] = {"1st-label-lookup-result", "2nd-label-lookup-result", "3th-label-lookup-result"};
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    DbgMplsHashEngineForLabel0Info_m  label0_info;
    DbgMplsHashEngineForLabel1Info_m  label1_info;
    DbgMplsHashEngineForLabel2Info_m  label2_info;
    DbgIpeMplsDecapInfo_m mpls_decap_info;

    sal_memset(&label0_info, 0, sizeof(label0_info));
    cmd = DRV_IOR(DbgMplsHashEngineForLabel0Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &label0_info));
    sal_memset(&label1_info, 0, sizeof(label1_info));
    cmd = DRV_IOR(DbgMplsHashEngineForLabel1Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &label1_info));
    sal_memset(&label2_info, 0, sizeof(label2_info));
    cmd = DRV_IOR(DbgMplsHashEngineForLabel2Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &label2_info));
    sal_memset(&mpls_decap_info, 0, sizeof(mpls_decap_info));
    cmd = DRV_IOR(DbgIpeMplsDecapInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &mpls_decap_info));

    if (!GetDbgIpeMplsDecapInfo(V, valid_f, &mpls_decap_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "Decapsulation")

    if (GetDbgIpeMplsDecapInfo(V, tunnelDecap0_f, &mpls_decap_info)
        || GetDbgIpeMplsDecapInfo(V, tunnelDecap1_f, &mpls_decap_info))
    {
        if (GetDbgIpeMplsDecapInfo(V, innerPacketLookup_f, &mpls_decap_info))
        {
            DIAG_INFO_CHAR(pos, "tunnel-process", "inner-packet-forward")
        }
        else
        {
            DIAG_INFO_CHAR(pos, "tunnel-process", "tunnel-forward")
        }
    }
    else if (GetDbgIpeMplsDecapInfo(V, isMplsSwitched_f, &mpls_decap_info))
    {
        uint8 i = 0;
        uint32 mpls_valid[3] = {
                GetDbgMplsHashEngineForLabel0Info(V, valid_f, &label0_info),
                GetDbgMplsHashEngineForLabel1Info(V, valid_f, &label1_info),
                GetDbgMplsHashEngineForLabel2Info(V, valid_f, &label2_info)};
        uint32 mpls_key_index[3] = {
                GetDbgMplsHashEngineForLabel0Info(V, keyIndex_f, &label0_info),
                GetDbgMplsHashEngineForLabel1Info(V, keyIndex_f, &label1_info),
                GetDbgMplsHashEngineForLabel2Info(V, keyIndex_f, &label2_info)};
        uint32 mpls_ad_index[3] =  {
                GetDbgMplsHashEngineForLabel0Info(V, dsAdIndex_f, &label0_info),
                GetDbgMplsHashEngineForLabel1Info(V, dsAdIndex_f, &label1_info),
                GetDbgMplsHashEngineForLabel2Info(V, dsAdIndex_f, &label2_info)};
        uint32 mpls_conflict[3] = {
                GetDbgMplsHashEngineForLabel0Info(V, mplsHashConflict_f, &label0_info),
                GetDbgMplsHashEngineForLabel1Info(V, mplsHashConflict_f, &label1_info),
                GetDbgMplsHashEngineForLabel2Info(V, mplsHashConflict_f, &label2_info)};
        uint32 mpls_result_valid[3] = {
                GetDbgMplsHashEngineForLabel0Info(V, lookupResultValid_f, &label0_info),
                GetDbgMplsHashEngineForLabel1Info(V, lookupResultValid_f, &label1_info),
                GetDbgMplsHashEngineForLabel2Info(V, lookupResultValid_f, &label2_info)};

        for (i = 0; i < 3; i++)
        {
            if (mpls_valid[i])
            {
                if (GetDbgIpeMplsDecapInfo(V, innerPacketLookup_f, &mpls_decap_info))
                {
                    DIAG_INFO_CHAR(pos, "mpls-process", "inner-packet-forward")
                }
                else
                {
                    DIAG_INFO_CHAR(pos, "mpls-process", "mpls-label-forward")
                }
                if (mpls_conflict[i])
                {
                    DIAG_INFO_CHAR(pos, str[i], DIAG_LOOKUP_CONFLICT)
                    DIAG_INFO_CHAR(pos, "key-name", "DsMplsLabelHashKey")
                    DIAG_INFO_UINT32(pos, "key-index", mpls_key_index[i])
                }
                else if (mpls_result_valid[i])
                {
                    DIAG_INFO_CHAR(pos, str[i], DIAG_LOOKUP_HIT)
                    DIAG_INFO_CHAR(pos, "key-name", "DsMplsLabelHashKey")
                    #if (0 == SDK_WORK_PLATFORM)
                    value = DRV_TABLE_MAX_INDEX(lchip, DsMplsHashCam_t);
                    DIAG_INFO_UINT32(pos, "key-index", (mpls_key_index[i]+value))
                    #endif
                    #if (1 == SDK_WORK_PLATFORM)
                    DIAG_INFO_UINT32(pos, "key-index", (mpls_key_index[i]))
                    #endif
                    DIAG_INFO_CHAR(pos, "ad-name",  "DsMpls")
                    //DIAG_INFO_CHAR(pos, "ad-name", ((mpls_key_index[i] < value) ? "DsMplsHashCamAd" : "DsMpls"))
                    DIAG_INFO_UINT32(pos, "ad-index", mpls_ad_index[i])
                    DIAG_INFO_CHAR(pos, "pop-lable", "YES")
                }
                else
                {
                    DIAG_INFO_CHAR(pos, str[i], DIAG_LOOKUP_HIT_NONE)
                }
            }
        }
    }

    if (GetDbgIpeMplsDecapInfo(V, policerValid0_f, &mpls_decap_info))
    {
        DIAG_INFO_UINT32(pos, "policer-ptr-0", GetDbgIpeMplsDecapInfo(V, policerPtr0_f, &mpls_decap_info))
    }
    if (GetDbgIpeMplsDecapInfo(V, policerValid1_f, &mpls_decap_info))
    {
        DIAG_INFO_UINT32(pos, "policer-ptr-1", GetDbgIpeMplsDecapInfo(V, policerPtr1_f, &mpls_decap_info))
    }
    /* Drop Process */
    _sys_tmm_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeMplsDecapInfo(V, discard_f, &mpls_decap_info),
                                          GetDbgIpeMplsDecapInfo(V, discardType_f, &mpls_decap_info));
    /* Exception Process */
    _sys_tmm_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeMplsDecapInfo(V, exceptionEn_f, &mpls_decap_info),
                                               GetDbgIpeMplsDecapInfo(V, exceptionIndex_f, &mpls_decap_info),
                                               GetDbgIpeMplsDecapInfo(V, exceptionSubIndex_f, &mpls_decap_info));

    return CTC_E_NONE;
}
STATIC int32
_sys_tmm_diag_pkt_trace_get_lkup_mgr_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint32 data[4] = {0};
    uint32 data_temp[4] = {0};
    uint8  pos = CTC_DIAG_TRACE_POS_IPE;
    uint8  decode_print_valid = 0;
    uint8  loop = 0;
    uint8  step = DbgProgramLtidTcamEngineIpeAclInfo_gAclLookup_1_lookupEn_f - DbgProgramLtidTcamEngineIpeAclInfo_gAclLookup_0_lookupEn_f;
    hw_mac_addr_t hw_mac = {0};
    DbgIpeLkpMgrInfo_m lkp_mgr_info;
    DbgFibLkpEngineMacSaHashInfo_m macsa_info;
    DbgFibLkpEngineTcamKeyInfo_m dbg_tcam_key;
/*    DbgFibLkpEngineHostUrpfHashInfo_m  urpf_info;*/
    DbgFibLkpEngineMacDaHashInfo_m  macda_info;
    DbgFibLkpEnginel3DaHashInfo_m   l3da_info;
    DbgFibLkpEnginel3SaHashInfo_m   l3sa_info;
    DbgProgramLtidTcamEngineIpeAclInfo_m ltid_info;
    union
    {
        DbgIpeLookupManagerUdfDecoder_m udf_decoder;
        DbgIpeLookupManagerOuterL2Decoder_m outer_l2_decoder;
        DbgIpeLookupManagerOuterL3Decoder_m outer_l3_decoder;
        DbgIpeLookupManagerOuterL4Decoder_m outer_l4_decoder;
        DbgIpeLookupManagerInnerL2Decoder_m inner_l2_decoder;
        DbgIpeLookupManagerInnerL3Decoder_m inner_l3_decoder;
        DbgIpeLookupManagerInnerL4Decoder_m inner_l4_decoder;
    } un;
    EfdDebugStats_m efd_dbg_stats;
    void* ds = (void*)&un.udf_decoder;


    sal_memset(&lkp_mgr_info, 0, sizeof(lkp_mgr_info));
    cmd = DRV_IOR(DbgIpeLkpMgrInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &lkp_mgr_info));

    if (!GetDbgIpeLkpMgrInfo(V, valid_f, &lkp_mgr_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "Lookup Manager")

    cmd = DRV_IOR(DbgProgramLtidTcamEngineIpeAclInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ltid_info));
    for (loop=0; loop<16; loop++)
    {
        cmd = DRV_IOR(DbgProgramAclTcamEngineIpeAclInfo0_t+loop, DbgProgramAclTcamEngineIpeAclInfo0_hit_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
        decode_print_valid = decode_print_valid || (!value && GetDbgProgramLtidTcamEngineIpeAclInfo(V, gAclLookup_0_lookupEn_f + step*loop, &ltid_info));
    }

    cmd = DRV_IOR(DbgIpeLookupManagerUdfDecoder_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, ds));
    if (GetDbgIpeLookupManagerUdfDecoder(V, valid_f, ds) && decode_print_valid)
    {
        DIAG_INFO_NONE(pos, "--UDF Decoder")
        if (0 != GetDbgIpeLookupManagerUdfDecoder(V, udfValid_f, ds))
        {
            sys_acl_udf_info_t udf_info = {0};
            uint16 udf_ad_id = GetDbgIpeLookupManagerUdfDecoder(V, udfHitIndex_f, ds);
            
            DIAG_INFO_CHAR(pos, "udf-lkup", DIAG_LOOKUP_HIT)
            value = GetDbgIpeLkpMgrInfo(V, udfHitIndex_f, &lkp_mgr_info);
            if (value >= 512)
            {
                DIAG_INFO_CHAR(pos, "sudf-en", DIAG_ENABLE)
            }
            DIAG_INFO_UINT32(pos, "key-index", value)
            DIAG_INFO_UINT32(pos, "udf-ad-id", udf_ad_id)
            
            GetDbgIpeLookupManagerUdfDecoder(A, udf_f, ds, data);
            sys_usw_acl_get_udf_info_by_ad_id(lchip, udf_ad_id, &udf_info);
            DIAG_SET_USR_UDF(udf_info.granularity, data_temp, data);
            DIAG_INFO_UDF(pos, "udf-data", data_temp);
        }
        else
        {
            DIAG_INFO_CHAR(pos, "udf-lkup", DIAG_LOOKUP_HIT_NONE)
        }
    }
    cmd = DRV_IOR(DbgIpeLookupManagerOuterL2Decoder_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, ds));
    if (GetDbgIpeLookupManagerOuterL2Decoder(V, valid_f, ds) && decode_print_valid)
    {
        DIAG_INFO_NONE(pos, "--Outer L2 Decoder")
        GetDbgIpeLookupManagerOuterL2Decoder(A, macDa_f, ds, data);
        DIAG_INFO_MAC(pos, "outer-mac-da", data)
        GetDbgIpeLookupManagerOuterL2Decoder(A, macSa_f, ds, data);
        DIAG_INFO_MAC(pos, "outer-mac-sa", data)
        DIAG_INFO_U32_HEX(pos, "outer-ether-type", GetDbgIpeLookupManagerOuterL2Decoder(V, etherType_f, ds))
        value = GetDbgIpeLookupManagerOuterL2Decoder(V, svlanTag_f, ds);
        DIAG_INFO_UINT32(pos, "outer-svlan-id", DIAG_DECODE_VLAN_ID(value))
        DIAG_INFO_UINT32(pos, "outer-scos", DIAG_DECODE_VLAN_COS(value))
        DIAG_INFO_UINT32(pos, "outer-scfi", DIAG_DECODE_VLAN_CFI(value))
        value = GetDbgIpeLookupManagerOuterL2Decoder(V, cvlanTag_f, ds);
        DIAG_INFO_UINT32(pos, "outer-cvlan-id", DIAG_DECODE_VLAN_ID(value))
        DIAG_INFO_UINT32(pos, "outer-ccos", DIAG_DECODE_VLAN_COS(value))
        DIAG_INFO_UINT32(pos, "outer-ccfi", DIAG_DECODE_VLAN_CFI(value))
        DIAG_INFO_U32_HEX(pos, "outer-data0", GetDbgIpeLookupManagerOuterL2Decoder(V, data0_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data1", GetDbgIpeLookupManagerOuterL2Decoder(V, data1_f, ds))
    }
    cmd = DRV_IOR(DbgIpeLookupManagerOuterL3Decoder_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, ds));
    if (GetDbgIpeLookupManagerOuterL3Decoder(V, valid_f, ds) && decode_print_valid)
    {
        DIAG_INFO_NONE(pos, "--Outer L3 Decoder")
        DIAG_INFO_U32_HEX(pos, "outer-data0", GetDbgIpeLookupManagerOuterL3Decoder(V, uF0_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data1", GetDbgIpeLookupManagerOuterL3Decoder(V, uF1_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data2", GetDbgIpeLookupManagerOuterL3Decoder(V, uF2_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data3", GetDbgIpeLookupManagerOuterL3Decoder(V, uF3_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data4", GetDbgIpeLookupManagerOuterL3Decoder(V, uF4_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data5", GetDbgIpeLookupManagerOuterL3Decoder(V, uF5_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data6", GetDbgIpeLookupManagerOuterL3Decoder(V, uF6_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data7", GetDbgIpeLookupManagerOuterL3Decoder(V, uF7_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data8", GetDbgIpeLookupManagerOuterL3Decoder(V, uF8_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data9", GetDbgIpeLookupManagerOuterL3Decoder(V, uF9_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data10", GetDbgIpeLookupManagerOuterL3Decoder(V, uF10_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data11", GetDbgIpeLookupManagerOuterL3Decoder(V, uF11_gField_data_f, ds))
    }
    cmd = DRV_IOR(DbgIpeLookupManagerOuterL4Decoder_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, ds));
    if (GetDbgIpeLookupManagerOuterL4Decoder(V, valid_f, ds) && decode_print_valid)
    {
        DIAG_INFO_NONE(pos, "--Outer L4 Decoder")
        DIAG_INFO_U32_HEX(pos, "outer-data0", GetDbgIpeLookupManagerOuterL4Decoder(V, uF0_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data1", GetDbgIpeLookupManagerOuterL4Decoder(V, uF1_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data2", GetDbgIpeLookupManagerOuterL4Decoder(V, uF2_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data3", GetDbgIpeLookupManagerOuterL4Decoder(V, uF3_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data4", GetDbgIpeLookupManagerOuterL4Decoder(V, uF4_gField_data_f, ds))
        DIAG_INFO_U32_HEX(pos, "outer-data5", GetDbgIpeLookupManagerOuterL4Decoder(V, uF5_gField_data_f, ds))
    }
    cmd = DRV_IOR(DbgIpeMplsDecapInfo_t, DbgIpeMplsDecapInfo_secondParserEn_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
    if (value != 0 && decode_print_valid)
    {
        cmd = DRV_IOR(DbgIpeLookupManagerInnerL2Decoder_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, ds));
        if (GetDbgIpeLookupManagerInnerL2Decoder(V, valid_f, ds))
        {
            DIAG_INFO_NONE(pos, "--Inner L2 Decoder")
            GetDbgIpeLookupManagerInnerL2Decoder(A, macDa_f, ds, data);
            DIAG_INFO_MAC(pos, "Inner-mac-da", data)
            GetDbgIpeLookupManagerInnerL2Decoder(A, macSa_f, ds, data);
            DIAG_INFO_MAC(pos, "Inner-mac-sa", data)
            DIAG_INFO_U32_HEX(pos, "Inner-ether-type", GetDbgIpeLookupManagerInnerL2Decoder(V, etherType_f, ds))
            value = GetDbgIpeLookupManagerInnerL2Decoder(V, svlanTag_f, ds);
            DIAG_INFO_UINT32(pos, "Inner-svlan-id", DIAG_DECODE_VLAN_ID(value))
            DIAG_INFO_UINT32(pos, "Inner-scos", DIAG_DECODE_VLAN_COS(value))
            DIAG_INFO_UINT32(pos, "Inner-scfi", DIAG_DECODE_VLAN_CFI(value))
            value = GetDbgIpeLookupManagerInnerL2Decoder(V, cvlanTag_f, ds);
            DIAG_INFO_UINT32(pos, "Inner-cvlan-id", DIAG_DECODE_VLAN_ID(value))
            DIAG_INFO_UINT32(pos, "Inner-ccos", DIAG_DECODE_VLAN_COS(value))
            DIAG_INFO_UINT32(pos, "Inner-ccfi", DIAG_DECODE_VLAN_CFI(value))
            DIAG_INFO_U32_HEX(pos, "Inner-data0", GetDbgIpeLookupManagerInnerL2Decoder(V, data0_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data1", GetDbgIpeLookupManagerInnerL2Decoder(V, data1_f, ds))
        }
        cmd = DRV_IOR(DbgIpeLookupManagerInnerL3Decoder_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, ds));
        if (GetDbgIpeLookupManagerInnerL3Decoder(V, valid_f, ds))
        {
            DIAG_INFO_NONE(pos, "--Inner L3 Decoder")
            DIAG_INFO_U32_HEX(pos, "Inner-data0", GetDbgIpeLookupManagerInnerL3Decoder(V, uF0_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data1", GetDbgIpeLookupManagerInnerL3Decoder(V, uF1_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data2", GetDbgIpeLookupManagerInnerL3Decoder(V, uF2_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data3", GetDbgIpeLookupManagerInnerL3Decoder(V, uF3_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data4", GetDbgIpeLookupManagerInnerL3Decoder(V, uF4_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data5", GetDbgIpeLookupManagerInnerL3Decoder(V, uF5_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data6", GetDbgIpeLookupManagerInnerL3Decoder(V, uF6_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data7", GetDbgIpeLookupManagerInnerL3Decoder(V, uF7_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data8", GetDbgIpeLookupManagerInnerL3Decoder(V, uF8_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data9", GetDbgIpeLookupManagerInnerL3Decoder(V, uF9_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data10", GetDbgIpeLookupManagerInnerL3Decoder(V, uF10_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data11", GetDbgIpeLookupManagerInnerL3Decoder(V, uF11_gField_data_f, ds))
        }
        cmd = DRV_IOR(DbgIpeLookupManagerInnerL4Decoder_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, ds));
        if (GetDbgIpeLookupManagerInnerL4Decoder(V, valid_f, ds))
        {
            DIAG_INFO_NONE(pos, "--Inner L4 Decoder")
            DIAG_INFO_U32_HEX(pos, "Inner-data0", GetDbgIpeLookupManagerInnerL4Decoder(V, uF0_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data1", GetDbgIpeLookupManagerInnerL4Decoder(V, uF1_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data2", GetDbgIpeLookupManagerInnerL4Decoder(V, uF2_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data3", GetDbgIpeLookupManagerInnerL4Decoder(V, uF3_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data4", GetDbgIpeLookupManagerInnerL4Decoder(V, uF4_gField_data_f, ds))
            DIAG_INFO_U32_HEX(pos, "Inner-data5", GetDbgIpeLookupManagerInnerL4Decoder(V, uF5_gField_data_f, ds))
        }
    }
    if (GetDbgIpeLkpMgrInfo(V, isInnerMacSaLookup_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "inner-macsa-lookup", "TRUE")
    }
    if (GetDbgIpeLkpMgrInfo(V, efdEnable_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "elephant-detect", "ENABLE")
    }
    if (GetDbgIpeLkpMgrInfo(V, isElephant_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "elephant-flow", "TURE")
    }
    if (GetDbgIpeLkpMgrInfo(V, isNewElephant_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "new-elephant-flow", "TURE")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv4Ucast_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-fwd-type", "IPv4-UC")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv4Mcast_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-fwd-type", "IPv4-MC")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv4UcastNat_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-fwd-type", "IPv4-UC-NAT")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv4UcastRpf_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-fwd-type", "IPv4-UC-RPF")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv6Ucast_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-fwd-type", "IPv6-UC")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv6Mcast_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-fwd-type", "IPv6-MC")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv6UcastNat_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-fwd-type", "IPv6-UC-NAT")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv6UcastRpf_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-fwd-type", "IPv6-UC-RPF")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv4IcmpErrMsg_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-type", "IPv4-ICMP-ERROR-MSG")
    }
    if (GetDbgIpeLkpMgrInfo(V, isIpv6IcmpErrMsg_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-type", "IPv6-ICMP-ERROR-MSG")
    }
    if (GetDbgIpeLkpMgrInfo(V, isTrillUcast_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-fwd-type", "TRILL-UC")
    }
    if (GetDbgIpeLkpMgrInfo(V, isTrillMcast_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-fwd-type", "TRILL-MC")
    }
    if (GetDbgIpeLkpMgrInfo(V, isFcoe_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-fwd-type", "FCoE")
    }
    if (GetDbgIpeLkpMgrInfo(V, isFcoeRpf_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-type", "FCoE-RPF")
    }
    if (GetDbgIpeLkpMgrInfo(V, ipv4McastAddressCheckFailure_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "ipv4mc-addr-check", "FAILURE")
    }
    if (GetDbgIpeLkpMgrInfo(V, ipv6McastAddressCheckFailure_f, &lkp_mgr_info))
    {
        DIAG_INFO_CHAR(pos, "ipv6mc-addr-check", "FAILURE")
    }

    sal_memset(&macda_info, 0, sizeof(macda_info));
    cmd = DRV_IOR(DbgFibLkpEngineMacDaHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &macda_info));
    if (GetDbgFibLkpEngineMacDaHashInfo(V, valid_f, &macda_info)
        && GetDbgFibLkpEngineMacDaHashInfo(V, gMacDaLkp_macDaLookupEn_f, &macda_info))
    {
        GetDbgFibLkpEngineMacDaHashInfo(A, gMacDaLkp_mappedMac_f, &macda_info, hw_mac);
        /*mac da lookup key*/
        DIAG_INFO_CHAR(pos, "macda-lookup", "ENABLE")
        DIAG_INFO_MAC(pos, "key-macda", hw_mac)
        DIAG_INFO_UINT32(pos, "key-fid", GetDbgFibLkpEngineMacDaHashInfo(V, gMacDaLkp_vsiId_f, &macda_info))
    }

    sal_memset(&macsa_info, 0, sizeof(macsa_info));
    cmd = DRV_IOR(DbgFibLkpEngineMacSaHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &macsa_info));
    if (GetDbgFibLkpEngineMacSaHashInfo(V, valid_f, &macsa_info)
        && GetDbgFibLkpEngineMacSaHashInfo(V, gMacSaLkp_macSaLookupEn_f, &macsa_info))
    {
        /*mac sa lookup key*/
        GetDbgFibLkpEngineMacSaHashInfo(A, gMacSaLkp_mappedMac_f, &macsa_info, hw_mac);
        DIAG_INFO_CHAR(pos, "macsa-lookup", "ENABLE")
        DIAG_INFO_MAC(pos, "key-macsa", hw_mac)
        DIAG_INFO_UINT32(pos, "key-fid", GetDbgFibLkpEngineMacSaHashInfo(V, gMacSaLkp_vsiId_f, &macsa_info))
    }

    sal_memset(&l3da_info, 0, sizeof(l3da_info));
    cmd = DRV_IOR(DbgFibLkpEnginel3DaHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &l3da_info));
    if (GetDbgFibLkpEnginel3DaHashInfo(V, valid_f, &l3da_info)
        && GetDbgFibLkpEnginel3DaHashInfo(V, l3DaLookupEn_f, &l3da_info))
    {
        /*l3 da lookup key*/
        int32 ret = 0;
        drv_acc_in_t acc_in;
        drv_acc_out_t acc_out;
        char* str_l3da[] = {"IPv4-UCAST", "IPv6-UCAST", "IPv4-MCAST",
                            "IPv6-MCAST", "FCoE", "TRILL-UCAST", "TRILL-MCAST", "RESERVED"};
        DIAG_INFO_CHAR(pos, "l3da-lookup", "ENABLE")
        value = GetDbgFibLkpEnginel3DaHashInfo(V, l3DaKeyType_f, &l3da_info);
        DIAG_INFO_CHAR(pos, "l3da-lkup-key-type", STR_ARRAY(str_l3da,value))

        sal_memset(&acc_in, 0, sizeof(acc_in));
        sal_memset(&acc_out, 0, sizeof(acc_out));
        switch (value)
        {
            case SYS_TMM_DIAG_L3DA_TYPE_IPV4UC:
                /*DsFibHost0Ipv4HashKey_t*/
                break;
            case SYS_TMM_DIAG_L3DA_TYPE_IPV6UC:
                /*DsFibHost0Ipv6UcastHashKey_t*/
                break;
            case SYS_TMM_DIAG_L3DA_TYPE_IPV4MC:
                /*DsFibHost0Ipv4HashKey_t*/
                break;
            case SYS_TMM_DIAG_L3DA_TYPE_IPV6MC:
                /*DsFibHost0MacIpv6McastHashKey_t*/
                break;
            case SYS_TMM_DIAG_L3DA_TYPE_TRILLUC:
                acc_in.index = GetDbgFibLkpEnginel3DaHashInfo(V, hostHashFirstL3DaKeyIndex_f, &l3da_info);
                acc_in.type = DRV_ACC_TYPE_LOOKUP;
                acc_in.tbl_id = DsFibHost0TrillHashKey_t;
                acc_in.op_type = DRV_ACC_OP_BY_INDEX;
                drv_acc_get_hash_module(lchip, acc_in.tbl_id, &acc_in.module);
                ret = drv_acc_api(lchip, &acc_in, &acc_out);
                if (ret == 0)
                {
                    DIAG_INFO_U32_HEX(pos, "key-egs-nickname", GetDsFibHost0TrillHashKey(V, egressNickname_f, acc_out.data))
                }
                break;
            case SYS_TMM_DIAG_L3DA_TYPE_TRILLMC:
                acc_in.index = GetDbgFibLkpEnginel3DaHashInfo(V, hostHashFirstL3DaKeyIndex_f, &l3da_info);
                acc_in.type = DRV_ACC_TYPE_LOOKUP;
                acc_in.tbl_id = DsFibHost1TrillMcastVlanHashKey_t;
                acc_in.op_type = DRV_ACC_OP_BY_INDEX;
                drv_acc_get_hash_module(lchip, acc_in.tbl_id, &acc_in.module);
                ret = drv_acc_api(lchip, &acc_in, &acc_out);
                if (ret == 0)
                {
                    DIAG_INFO_U32_HEX(pos, "key-egs-nickname", GetDsFibHost1TrillMcastVlanHashKey(V, egressNickname_f, acc_out.data))
                    DIAG_INFO_U32_HEX(pos, "key-vlan-id", GetDsFibHost1TrillMcastVlanHashKey(V, vlanId_f, acc_out.data))
                }
                break;
            case SYS_TMM_DIAG_L3DA_TYPE_FCOE:
                acc_in.index = GetDbgFibLkpEnginel3DaHashInfo(V, hostHashFirstL3DaKeyIndex_f, &l3da_info);
                acc_in.type = DRV_ACC_TYPE_LOOKUP;
                acc_in.tbl_id = DsFibHost0FcoeHashKey_t;
                acc_in.op_type = DRV_ACC_OP_BY_INDEX;
                drv_acc_get_hash_module(lchip, acc_in.tbl_id, &acc_in.module);
                ret = drv_acc_api(lchip, &acc_in, &acc_out);
                if (ret == 0)
                {
                    DIAG_INFO_U32_HEX(pos, "key-fcid", GetDsFibHost0FcoeHashKey(V, fcoeDid_f, acc_out.data))
                    DIAG_INFO_U32_HEX(pos, "key-fid", GetDsFibHost0FcoeHashKey(V, vsiId_f, acc_out.data))
                }
                break;
            default:
                break;
        }
    }

    sal_memset(&l3sa_info, 0, sizeof(l3sa_info));
    cmd = DRV_IOR(DbgFibLkpEnginel3SaHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &l3sa_info));
    if (GetDbgFibLkpEnginel3SaHashInfo(V, valid_f, &l3sa_info)
        && GetDbgFibLkpEnginel3SaHashInfo(V, l3SaLookupEn_f, &l3sa_info))
    {

        char* str_l3sa[] = {"IPv4-RPF", "IPv6-RPF", "IPv4-PBR",
                            "IPv6-PBR", "IPv4-NATSA", "IPv6-NATSA", "FCoE-RPF"};
        /*l3 da lookup key*/
        DIAG_INFO_CHAR(pos, "l3sa-lookup", "ENABLE")
        value = GetDbgFibLkpEnginel3SaHashInfo(V, l3SaKeyType_f, &l3sa_info);
        DIAG_INFO_CHAR(pos, "l3sa-lkup-key-type", STR_ARRAY(str_l3sa,value))
    }

    cmd = DRV_IOR(DbgFibLkpEngineTcamKeyInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &dbg_tcam_key));
    if (GetDbgFibLkpEngineTcamKeyInfo(V, valid_f, &dbg_tcam_key))
    {
        uint32 value_array[6] = {0};
        uint8 hit = 0;
        if (GetDbgFibLkpEngineTcamKeyInfo(V, dbgFromNatDaLookup_f, &dbg_tcam_key))
        {
            DIAG_INFO_CHAR(pos, "natda-lookup", "ENABLE")
            GetDbgFibLkpEngineTcamKeyInfo(A, dbgNatDaHashKey_f, &dbg_tcam_key, value_array);
            DIAG_INFO_U32_LIST(pos, "natda-key", value_array, 6)
            if (GetDbgFibLkpEngineTcamKeyInfo(V, l3NatDaTcamResultValid_f, &dbg_tcam_key))
            {
                DIAG_INFO_CHAR(pos, "natda-tcam-lookup", "HIT")
                DIAG_INFO_UINT32(pos, "natda-tcam-index", GetDbgFibLkpEngineTcamKeyInfo(V, l3NatDaResultTcamEntryIndex_f, &dbg_tcam_key))
            }
            else
            {
                DIAG_INFO_CHAR(pos, "natda-tcam-lookup", "HIT-NONE")
            }

        }

        if (GetDbgFibLkpEngineTcamKeyInfo(V, dbgFromNatSaLookup_f, &dbg_tcam_key))
        {
            DIAG_INFO_CHAR(pos, "natsa-lookup", "ENABLE")
            GetDbgFibLkpEngineTcamKeyInfo(A, dbgNatSaHashKey_f, &dbg_tcam_key, value_array);
            DIAG_INFO_U32_LIST(pos, "natsa-key", value_array, 6)
            if (GetDbgFibLkpEngineTcamKeyInfo(V, l3NatSaTcamResultValid_f, &dbg_tcam_key))
            {
                DIAG_INFO_CHAR(pos, "natsa-tcam-lookup", "HIT")
                DIAG_INFO_UINT32(pos, "natsa-tcam-index", GetDbgFibLkpEngineTcamKeyInfo(V, l3NatSaResultTcamEntryIndex_f, &dbg_tcam_key))
            }
            else
            {
                DIAG_INFO_CHAR(pos, "natsa-tcam-lookup", "HIT-NONE")
            }
        }
        if ((GetDbgFibLkpEnginel3DaHashInfo(V, valid_f, &l3da_info)
        && GetDbgFibLkpEnginel3DaHashInfo(V, l3DaLookupEn_f, &l3da_info)))
        {
            GetDbgFibLkpEngineTcamKeyInfo(A, dbgLpmDaHashKey_f, &dbg_tcam_key, value_array);
            DIAG_INFO_U32_LIST(pos, "lpmda-tcam-key", value_array, 6)
            if (GetDbgFibLkpEngineTcamKeyInfo(V, lpmDaPrivate1ResultValid_f, &dbg_tcam_key))
            {
                DIAG_INFO_CHAR(pos, "lpmda-private1-lookup", "HIT")
                DIAG_INFO_UINT32(pos, "tcam-hit-index", GetDbgFibLkpEngineTcamKeyInfo(V, lpmDaPrivate1TcamHitIndex_f, &dbg_tcam_key))
                hit = 1;
            }
            if (GetDbgFibLkpEngineTcamKeyInfo(V, lpmDaPrivate2ResultValid_f, &dbg_tcam_key))
            {
                DIAG_INFO_CHAR(pos, "lpmda-private2-lookup", "HIT")
                DIAG_INFO_UINT32(pos, "tcam-hit-index", GetDbgFibLkpEngineTcamKeyInfo(V, lpmDaPrivate2TcamHitIndex_f, &dbg_tcam_key))
                hit = 1;
            }
            if (GetDbgFibLkpEngineTcamKeyInfo(V, lpmDaPublic1ResultValid_f, &dbg_tcam_key))
            {
                DIAG_INFO_CHAR(pos, "lpmda-public1-lookup", "HIT")
                DIAG_INFO_UINT32(pos, "tcam-hit-index", GetDbgFibLkpEngineTcamKeyInfo(V, lpmDaPublic1TcamHitIndex_f, &dbg_tcam_key))
                hit = 1;
            }
            if (GetDbgFibLkpEngineTcamKeyInfo(V, lpmDaPublic2ResultValid_f, &dbg_tcam_key))
            {
                DIAG_INFO_CHAR(pos, "lpmda-public2-lookup", "HIT")
                DIAG_INFO_UINT32(pos, "tcam-hit-index", GetDbgFibLkpEngineTcamKeyInfo(V, lpmDaPublic2TcamHitIndex_f, &dbg_tcam_key))
                hit = 1;
            }
            if (!hit)
            {
                DIAG_INFO_CHAR(pos, "lpmda-tcam-lookup", "HIT-NONE")
            }
        }
        if ((GetDbgFibLkpEnginel3SaHashInfo(V, valid_f, &l3sa_info)
        && GetDbgFibLkpEnginel3SaHashInfo(V, l3SaLookupEn_f, &l3sa_info)))
        {
            hit = 0;
            GetDbgFibLkpEngineTcamKeyInfo(A, dbgLpmSaHashKey_f, &dbg_tcam_key, value_array);
            DIAG_INFO_U32_LIST(pos, "lpmsa-tcam-key", value_array, 6)
            if (GetDbgFibLkpEngineTcamKeyInfo(V, lpmSaPrivate1ResultValid_f, &dbg_tcam_key))
            {
                DIAG_INFO_CHAR(pos, "lpmsa-private1-lookup", "HIT")
                DIAG_INFO_UINT32(pos, "tcam-hit-index", GetDbgFibLkpEngineTcamKeyInfo(V, lpmSaPrivate1TcamHitIndex_f, &dbg_tcam_key))
                hit = 1;
            }
            if (GetDbgFibLkpEngineTcamKeyInfo(V, lpmSaPrivate2ResultValid_f, &dbg_tcam_key))
            {
                DIAG_INFO_CHAR(pos, "lpmsa-private2-lookup", "HIT")
                DIAG_INFO_UINT32(pos, "tcam-hit-index", GetDbgFibLkpEngineTcamKeyInfo(V, lpmSaPrivate2TcamHitIndex_f, &dbg_tcam_key))
                hit = 1;
            }
            if (GetDbgFibLkpEngineTcamKeyInfo(V, lpmSaPublic1ResultValid_f, &dbg_tcam_key))
            {
                DIAG_INFO_CHAR(pos, "lpmsa-public1-lookup", "HIT")
                DIAG_INFO_UINT32(pos, "tcam-hit-index", GetDbgFibLkpEngineTcamKeyInfo(V, lpmSaPublic1TcamHitIndex_f, &dbg_tcam_key))
                hit = 1;
            }
            if (GetDbgFibLkpEngineTcamKeyInfo(V, lpmSaPublic2ResultValid_f, &dbg_tcam_key))
            {
                DIAG_INFO_CHAR(pos, "lpmsa-public2-lookup", "HIT")
                DIAG_INFO_UINT32(pos, "tcam-hit-index", GetDbgFibLkpEngineTcamKeyInfo(V, lpmSaPublic2TcamHitIndex_f, &dbg_tcam_key))
                hit = 1;
            }
            if (!hit)
            {
                DIAG_INFO_CHAR(pos, "lpmsa-tcam-lookup", "HIT-NONE")
            }
        }
    }
    if(!DRV_IS_TMG(lchip))
    {
    cmd = DRV_IOR(EfdDebugStats_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &efd_dbg_stats));
    DIAG_INFO_UINT32(pos, "efd-aging-cnt", GetEfdDebugStats(V, agingCnt_f, &efd_dbg_stats))
    DIAG_INFO_UINT32(pos, "efd-detect-cnt", GetEfdDebugStats(V, detectCnt_f, &efd_dbg_stats))
    DIAG_INFO_UINT32(pos, "efd-cpu-access-cnt", GetEfdDebugStats(V, cpuAccessCnt_f, &efd_dbg_stats))
    DIAG_INFO_UINT32(pos, "efd-insert-cnt", GetEfdDebugStats(V, insertCnt_f, &efd_dbg_stats))
    DIAG_INFO_UINT32(pos, "efd-update-cnt", GetEfdDebugStats(V, updateCnt_f, &efd_dbg_stats))
    DIAG_INFO_UINT32(pos, "efd-hash-conflict-cnt", GetEfdDebugStats(V, hashConflictCnt_f, &efd_dbg_stats))
    }
    /* Drop Process */
    _sys_tmm_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeLkpMgrInfo(V, discard_f, &lkp_mgr_info),
                                          GetDbgIpeLkpMgrInfo(V, discardType_f, &lkp_mgr_info));
    /* Exception Process */
    _sys_tmm_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeLkpMgrInfo(V, exceptionEn_f, &lkp_mgr_info),
                                               GetDbgIpeLkpMgrInfo(V, exceptionIndex_f, &lkp_mgr_info),
                                               GetDbgIpeLkpMgrInfo(V, exceptionSubIndex_f, &lkp_mgr_info));
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_flow_hash_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    char*  str_hash_key_name[] = {"Invalid", "DsFlowL2HashKey", "DsFlowL2L3HashKey", "DsFlowL3Ipv4HashKey",
                                    "DsFlowL3Ipv6HashKey", "DsFlowL3MplsHashKey", "Reserved", "DsFlowNshHashKey"};
    char*  str_field_sel_name[] = {"Invalid", "FlowL2HashFieldSelect", "FlowL2L3HashFieldSelect", "FlowL3Ipv4HashFieldSelect",
                                    "FlowL3Ipv6HashFieldSelect", "FlowL3MplsHashFieldSelect", "Reserved", "FlowNshHashFieldSelect"};
    DbgFibLkpEngineFlowHashInfo_m flow_hash_info;
    DbgIpeFlowProcessInfo_m flow_pro_info;
    sal_memset(&flow_hash_info, 0, sizeof(flow_hash_info));
    cmd = DRV_IOR(DbgFibLkpEngineFlowHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &flow_hash_info));
    sal_memset(&flow_pro_info, 0, sizeof(flow_pro_info));
    cmd = DRV_IOR(DbgIpeFlowProcessInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &flow_pro_info));

    if (!GetDbgIpeFlowProcessInfo(V, valid_f, &flow_pro_info))
    {
        return CTC_E_NONE;
    }
    /*hash*/
    if (GetDbgFibLkpEngineFlowHashInfo(V, valid_f, &flow_hash_info)
        && GetDbgFibLkpEngineFlowHashInfo(V, flowHashLookupEn_f, &flow_hash_info))
    {
        DIAG_INFO_NONE(pos, "Flow Hash")
        p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
        DIAG_INFO_NONE(pos, "flow-hash-lkup-info")
        DIAG_INFO_UINT32(pos, "global-port", SYS_MAP_DRV_GPORT_TO_CTC_GPORT(GetDbgFibLkpEngineFlowHashInfo(V, globalPort_f, &flow_hash_info)))
        DIAG_INFO_UINT32(pos, "local-port", GetDbgFibLkpEngineFlowHashInfo(V, localPhyPort_f, &flow_hash_info))
        DIAG_INFO_UINT32(pos, "logic-port", GetDbgFibLkpEngineFlowHashInfo(V, logicPort_f, &flow_hash_info))
        DIAG_INFO_UINT32(pos, "layer2-type", GetDbgFibLkpEngineFlowHashInfo(V, layer2Type_f, &flow_hash_info))
        DIAG_INFO_UINT32(pos, "layer3-type", GetDbgFibLkpEngineFlowHashInfo(V, layer3Type_f, &flow_hash_info))
        DIAG_INFO_UINT32(pos, "layer4-type", GetDbgFibLkpEngineFlowHashInfo(V, layer4Type_f, &flow_hash_info))
        DIAG_INFO_UINT32(pos, "layer4-user-type", GetDbgFibLkpEngineFlowHashInfo(V, layer4UserType_f, &flow_hash_info))
        DIAG_INFO_CHAR(pos, "pkt-svlan", GetDbgFibLkpEngineFlowHashInfo(V, prSlanIdValid_f, &flow_hash_info)? "Tagged": "Untagged")
        DIAG_INFO_CHAR(pos, "pkt-cvlan", GetDbgFibLkpEngineFlowHashInfo(V, prCvlanIdValid_f, &flow_hash_info)? "Tagged": "Untagged")
        DIAG_INFO_UINT32(pos, "layer2-decode-index", GetDbgFibLkpEngineFlowHashInfo(V, l2DecoderIndex_f, &flow_hash_info))
        DIAG_INFO_UINT32(pos, "layer3-decode-index", GetDbgFibLkpEngineFlowHashInfo(V, l3DecoderIndex_f, &flow_hash_info))
        DIAG_INFO_UINT32(pos, "layer4-decode-index", GetDbgFibLkpEngineFlowHashInfo(V, l4DecoderIndex_f, &flow_hash_info))
        if (GetDbgFibLkpEngineFlowHashInfo(V, svlanIdValid_f, &flow_hash_info))
        {
            DIAG_INFO_UINT32(pos, "svlan-id", GetDbgFibLkpEngineFlowHashInfo(V, svlanId_f, &flow_hash_info))
            DIAG_INFO_UINT32(pos, "stag-cos", GetDbgFibLkpEngineFlowHashInfo(V, stagCos_f, &flow_hash_info))
            DIAG_INFO_UINT32(pos, "stag-cfi", GetDbgFibLkpEngineFlowHashInfo(V, stagCfi_f, &flow_hash_info))
        }
        if (GetDbgFibLkpEngineFlowHashInfo(V, cvlanIdValid_f, &flow_hash_info))
        {
            DIAG_INFO_UINT32(pos, "cvlan-id", GetDbgFibLkpEngineFlowHashInfo(V, cvlanId_f, &flow_hash_info))
            DIAG_INFO_UINT32(pos, "ctag-cos", GetDbgFibLkpEngineFlowHashInfo(V, ctagCos_f, &flow_hash_info))
            DIAG_INFO_UINT32(pos, "ctag-cfi", GetDbgFibLkpEngineFlowHashInfo(V, ctagCfi_f, &flow_hash_info))
        }
        DIAG_INFO_UINT32(pos, "label-num", GetDbgFibLkpEngineFlowHashInfo(V, labelNumOrIpInfo_f, &flow_hash_info))
        value = GetDbgFibLkpEngineFlowHashInfo(V, ipPktLenRangeId_f, &flow_hash_info);
        value = (value << 8) + GetDbgFibLkpEngineFlowHashInfo(V, l4PortRangeBitmap_f, &flow_hash_info);
        DIAG_INFO_UINT32(pos, "range-bmp", value)
        if (GetDbgFibLkpEngineFlowHashInfo(V, ipRoutedPacket_f, &flow_hash_info))
        {
            DIAG_INFO_CHAR(pos, "ip-route-pkt", "Yes")
        }
        if (GetDbgFibLkpEngineFlowHashInfo(V, isNvgre_f, &flow_hash_info))
        {
            DIAG_INFO_CHAR(pos, "nvgre-pkt", "Yes")
        }
        DIAG_INFO_CHAR(pos, "flow-hash-match", GetDbgFibLkpEngineFlowHashInfo(V, flowHashUsePiVlan_f, &flow_hash_info)? "PI Vlan": "Pkt Vlan")
        switch(GetDbgFibLkpEngineFlowHashInfo(V, metadataType_f, &flow_hash_info))
        {
            case DIAG_ACL_METADATA_TYPE_METADATA:
            {
                DIAG_INFO_UINT32(pos, "metadata", GetDbgFibLkpEngineFlowHashInfo(V, metadata_f, &flow_hash_info))
                break;
            }
            case DIAG_ACL_METADATA_TYPE_FID:
            {
                DIAG_INFO_UINT32(pos, "fid", GetDbgFibLkpEngineFlowHashInfo(V, metadata_f, &flow_hash_info))
                break;
            }
            case DIAG_ACL_METADATA_TYPE_VRFID:
            {
                DIAG_INFO_UINT32(pos, "vrfid", GetDbgFibLkpEngineFlowHashInfo(V, metadata_f, &flow_hash_info))
                break;
            }
            case DIAG_ACL_METADATA_TYPE_INVALID:
            default:
                break;
        }
        DIAG_INFO_UINT32(pos, "vrfid", GetDbgFibLkpEngineFlowHashInfo(V, vrfId_f, &flow_hash_info))
        value = GetDbgFibLkpEngineFlowHashInfo(V, hashKeyType_f, &flow_hash_info);
        if (GetDbgFibLkpEngineFlowHashInfo(V, hashConflict_f, &flow_hash_info))
        {
            DIAG_INFO_CHAR(pos, "flow-hash-lkup-result", DIAG_LOOKUP_CONFLICT)
            DIAG_INFO_CHAR(pos, "key-name", STR_ARRAY(str_hash_key_name,value))
            DIAG_INFO_UINT32(pos, "key-index", GetDbgFibLkpEngineFlowHashInfo(V, keyIndex_f, &flow_hash_info))

        }
        else if (GetDbgFibLkpEngineFlowHashInfo(V, lookupResultValid_f, &flow_hash_info))
        {
            DIAG_INFO_CHAR(pos, "flow-hash-lkup-result", DIAG_LOOKUP_HIT)
            DIAG_INFO_CHAR(pos, "key-name", STR_ARRAY(str_hash_key_name,value))
            DIAG_INFO_UINT32(pos, "key-index", GetDbgFibLkpEngineFlowHashInfo(V, keyIndex_f, &flow_hash_info))
            DIAG_INFO_CHAR(pos, "ad-name", "DsFlow")
            DIAG_INFO_UINT32(pos, "ad-index", GetDbgFibLkpEngineFlowHashInfo(V, dsAdIndex_f, &flow_hash_info))
            DIAG_INFO_CHAR(pos, "field-sel-name", STR_ARRAY(str_field_sel_name,value))
            DIAG_INFO_UINT32(pos, "field-sel", GetDbgFibLkpEngineFlowHashInfo(V, flowFieldSel_f, &flow_hash_info))
        }
        else
        {
            DIAG_INFO_CHAR(pos, "flow-hash-lkup-result", DIAG_LOOKUP_HIT_NONE)
        }
    }

    /* Drop Process */
    _sys_tmm_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeFlowProcessInfo(V, discard_f, &flow_pro_info),
                                          GetDbgIpeFlowProcessInfo(V, discardType_f, &flow_pro_info));
    /* Exception Process */
    _sys_tmm_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeFlowProcessInfo(V, exceptionEn_f, &flow_pro_info),
                                               GetDbgIpeFlowProcessInfo(V, exceptionIndex_f, &flow_pro_info),
                                               GetDbgIpeFlowProcessInfo(V, exceptionSubIndex_f, &flow_pro_info));
    return CTC_E_NONE;
}


STATIC int32
_sys_tmm_diag_pkt_trace_get_ipe_bridge_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 value = 0;
    uint32 value1 = 0;
    uint32 fid = 0;
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    drv_acc_in_t  in;
    drv_acc_out_t out;
    hw_mac_addr_t hw_mac = {0};
    ipv6_addr_t   hw_ipv6 = {0};
    DbgFibLkpEngineMacDaHashInfo_m mac_da_info;
    DbgIpeMacBridgingInfo_m mac_bridge_info;
    DbgFibLkpEngineFibHashInfo_m fib_info;
    DbgFibLkpEngineFibHost0KeyInfo_m fib_key_info;

    sal_memset(&in, 0, sizeof(drv_acc_in_t));
    sal_memset(&out, 0, sizeof(drv_acc_out_t));

    sal_memset(&mac_da_info, 0, sizeof(mac_da_info));
    cmd = DRV_IOR(DbgFibLkpEngineMacDaHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &mac_da_info));
    sal_memset(&mac_bridge_info, 0, sizeof(mac_bridge_info));
    cmd = DRV_IOR(DbgIpeMacBridgingInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &mac_bridge_info));
    sal_memset(&fib_info, 0, sizeof(fib_info));
    cmd = DRV_IOR(DbgFibLkpEngineFibHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &fib_info));
    sal_memset(&fib_key_info, 0, sizeof(fib_key_info));
    cmd = DRV_IOR(DbgFibLkpEngineFibHost0KeyInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &fib_key_info));

    /*bridge process*/
    if (GetDbgIpeMacBridgingInfo(V, valid_f, &mac_bridge_info))
    {
        if (GetDbgFibLkpEngineMacDaHashInfo(V, gMacDaLkp_macDaLookupEn_f, &mac_da_info)
            && GetDbgIpeMacBridgingInfo(V, bridgePacket_f, &mac_bridge_info))
        {
            DIAG_INFO_NONE(pos, "Layer2 Bridging")
            p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
            if (GetDbgFibLkpEngineFibHashInfo(V, valid_f, &fib_info) && GetDbgFibLkpEngineFibHashInfo(V, macDaLookupEn_f, &fib_info))
            {
                DIAG_INFO_CHAR(pos, "macda-lookup", DIAG_ENABLE)
                switch(GetDbgFibLkpEngineFibHost0KeyInfo(V, dbgL2DaHashKeyType_f, &fib_key_info))
                {
                case 4: /*FIBHOST0HASHTYPE_MAC*/
                    GetDbgFibLkpEngineFibHashInfo(A, macDa_f, &fib_info, hw_mac);
                    DIAG_INFO_CHAR(pos, "key-type", "MAC")
                    DIAG_INFO_MAC(pos, "mac-da", hw_mac)
                    DIAG_INFO_UINT32(pos, "fid", GetDbgFibLkpEngineFibHashInfo(V, vsiId_f, &fib_info))
                    break;
                case 5: /*FIBHOST0HASHTYPE_MACIPV6MCAST*/
                    GetDbgFibLkpEngineFibHashInfo(A, l3Dest_f, &fib_info, hw_ipv6);
                    DIAG_INFO_CHAR(pos, "key-type", "MACIPV6MCAST")
                    DIAG_INFO_IP6(pos, "ipv6-da", hw_ipv6)
                    DIAG_INFO_UINT32(pos, "fid", GetDbgFibLkpEngineFibHashInfo(V, vsiId_f, &fib_info))
                    break;
                case 7: /*FIBHOST0HASHTYPE_MACIPV4MCAST*/
                    GetDbgFibLkpEngineFibHashInfo(A, l3Dest_f, &fib_info, hw_ipv6);
                    DIAG_INFO_CHAR(pos, "key-type", "MACIPV4MCAST")
                    DIAG_INFO_CHAR(pos, "ipv4-type", "L2MC")
                    DIAG_INFO_IP4(pos, "ipv4-da", hw_ipv6[0])
                    DIAG_INFO_UINT32(pos, "fid", GetDbgFibLkpEngineFibHashInfo(V, vsiId_f, &fib_info))
                    break;
                default:
                    break;
                }
            }
            if (GetDbgIpeMacBridgingInfo(V, macDaResultValid_f, &mac_bridge_info))
            {
                fid = GetDbgFibLkpEngineMacDaHashInfo(V, gMacDaLkp_vsiId_f, &mac_da_info);
                if (GetDbgFibLkpEngineMacDaHashInfo(V, blackHoleMacDaResultValid_f, &mac_da_info))
                {
                    value = GetDbgFibLkpEngineMacDaHashInfo(V, blackHoleHitMacDaKeyIndex_f, &mac_da_info);
                    cmd = DRV_IOR(DsFibMacBlackHoleHashKey_t, DsFibMacBlackHoleHashKey_dsAdIndex_f);
                    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, value, cmd, &value1));

                    DIAG_INFO_CHAR(pos, "macda-lookup-result", "HIT-BLACKHOLE-ENTRY")
                    DIAG_INFO_CHAR(pos, "key-name", "DsFibMacBlackHoleHashKey")
                    DIAG_INFO_UINT32(pos, "key-index", value)
                    DIAG_INFO_CHAR(pos, "ad-name", "DsMac")
                    DIAG_INFO_UINT32(pos, "ad-index", value1)
                }
                else if (GetDbgIpeMacBridgingInfo(V, macDaDefaultEntryValid_f, &mac_bridge_info))
                {
                    cmd = DRV_IOR(FibEngineLookupResultCtl_t, FibEngineLookupResultCtl_gMacDaLookupResultCtl_defaultEntryBase_f);
                    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                    DIAG_INFO_CHAR(pos, "macda-lookup-result", DIAG_LOOKUP_DEFAULT)
                    DIAG_INFO_UINT32(pos, "bridge-fid", fid)
                    DIAG_INFO_CHAR(pos, "ad-name", "DsMac")
                    DIAG_INFO_UINT32(pos, "ad-index", (fid + (value << 8)))
                }
                else if (GetDbgFibLkpEngineMacDaHashInfo(V, valid_f, &mac_da_info)
                    && GetDbgFibLkpEngineMacDaHashInfo(V, gMacDaLkpResult_macDaResultValid_f, &mac_da_info))
                {
                    value = GetDbgFibLkpEngineFibHost0KeyInfo(V, dbgL2DaKeyIndex_f, &fib_key_info);
                    value1 = GetDbgFibLkpEngineFibHost0KeyInfo(V, dbgL2DaAdIndex_f, &fib_key_info);

                    DIAG_INFO_CHAR(pos, "macda-lookup-result", DIAG_LOOKUP_HIT)
                    DIAG_INFO_CHAR(pos, "key-name", "DsFibHost0MacHashKey")
                    DIAG_INFO_UINT32(pos, "key-index", value)
                    DIAG_INFO_CHAR(pos, "ad-name", "DsMac")
                    DIAG_INFO_UINT32(pos, "ad-index", value1)

                }
                else
                {
                    DIAG_INFO_CHAR(pos, "macda-lookup-result", DIAG_LOOKUP_HIT_NONE)
                }
            }
            if (GetDbgIpeMacBridgingInfo(V, bridgeEscape_f, &mac_bridge_info))
            {
                DIAG_INFO_CHAR(pos, "bridge-escape", "ENABLE")
            }
            if (GetDbgIpeMacBridgingInfo(V, stormCtlEn_f, &mac_bridge_info))
            {
                DIAG_INFO_CHAR(pos, "bridge-stromctl", "ENABLE")
            }
        }

        /* Drop Process */
        _sys_tmm_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                            GetDbgIpeMacBridgingInfo(V, discard_f, &mac_bridge_info),
                                            GetDbgIpeMacBridgingInfo(V, discardType_f, &mac_bridge_info));
        /* Exception Process */
        _sys_tmm_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                                GetDbgIpeMacBridgingInfo(V, exceptionEn_f, &mac_bridge_info),
                                                GetDbgIpeMacBridgingInfo(V, exceptionIndex_f, &mac_bridge_info),
                                                GetDbgIpeMacBridgingInfo(V, exceptionSubIndex_f, &mac_bridge_info));
    }
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_ipe_learn_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 value = 0;
    uint32 ad_index = 0;
    uint32 fid = 0;
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    hw_mac_addr_t hw_mac = {0};
    DbgFibLkpEngineMacSaHashInfo_m mac_sa_info;
    DbgIpeMacLearningInfo_m mac_learn_info;
    DbgFibLkpEngineFibHashInfo_m fib_info;
    DbgIpeFwdProcessInfo_m fwd_proc_info;
    drv_acc_in_t  in;
    drv_acc_out_t out;

    sal_memset(&in, 0, sizeof(drv_acc_in_t));
    sal_memset(&out, 0, sizeof(drv_acc_out_t));
    sal_memset(&mac_learn_info, 0, sizeof(mac_learn_info));
    cmd = DRV_IOR(DbgIpeMacLearningInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &mac_learn_info));
    sal_memset(&mac_sa_info, 0, sizeof(mac_sa_info));
    cmd = DRV_IOR(DbgFibLkpEngineMacSaHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &mac_sa_info));
    sal_memset(&fib_info, 0, sizeof(fib_info));
    cmd = DRV_IOR(DbgFibLkpEngineFibHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &fib_info));
    cmd = DRV_IOR(DbgIpeFwdProcessInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &fwd_proc_info));

    if (!GetDbgIpeMacLearningInfo(V, valid_f, &mac_learn_info))
    {
       return CTC_E_NONE;
    }
    if (GetDbgIpeMacLearningInfo(V, valid_f, &mac_learn_info)
        && GetDbgFibLkpEngineMacSaHashInfo(V, gMacSaLkp_macSaLookupEn_f, &mac_sa_info))
    {
        DIAG_INFO_NONE(pos, "Learning")
        p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
        fid = GetDbgIpeMacLearningInfo(V, learningFid_f, &mac_learn_info);

        if (GetDbgFibLkpEngineFibHashInfo(V, valid_f, &fib_info) && GetDbgFibLkpEngineFibHashInfo(V, macSaLookupEn_f, &fib_info))
        {
            DIAG_INFO_CHAR(pos, "macsa-lookup", DIAG_ENABLE)
            GetDbgFibLkpEngineFibHashInfo(A, macSa_f, &fib_info, hw_mac);
            DIAG_INFO_MAC(pos, "mac-sa", hw_mac)
            DIAG_INFO_UINT32(pos, "fid", GetDbgFibLkpEngineFibHashInfo(V, vsiId_f, &fib_info))
        }

        if (GetDbgIpeMacLearningInfo(V, macSaHashConflict_f, &mac_learn_info))
        {
            DIAG_INFO_CHAR(pos, "macsa-lookup-result", DIAG_LOOKUP_CONFLICT)
            value = GetDbgFibLkpEngineMacSaHashInfo(V, gMacSaLkpResult_macSaHashKeyHitIndex_f, &mac_sa_info);
            in.type = DRV_ACC_TYPE_LOOKUP;
            in.tbl_id = DsFibHost0MacHashKey_t;
            in.index =  value;
            in.op_type = DRV_ACC_OP_BY_INDEX;
            drv_acc_get_hash_module(lchip, in.tbl_id, &in.module);
            CTC_ERROR_RETURN(drv_acc_api(lchip, &in, &out));
            drv_get_field(lchip, DsFibHost0MacHashKey_t, DsFibHost0MacHashKey_dsAdIndex_f, out.data, &ad_index);
            DIAG_INFO_CHAR(pos, "key-name", "DsFibHost0MacHashKey")
            DIAG_INFO_UINT32(pos, "key-index", value)
            DIAG_INFO_CHAR(pos, "ad-name", "DsMac")
            DIAG_INFO_UINT32(pos, "ad-index", ad_index)
        }
        else if (GetDbgIpeMacLearningInfo(V, macSaResultValid_f, &mac_learn_info)&&(!GetDbgIpeMacLearningInfo(V, macSaDefaultEntryValid_f, &mac_learn_info)))
        {
            DIAG_INFO_CHAR(pos, "macsa-lookup-result", DIAG_LOOKUP_HIT)
            value = GetDbgFibLkpEngineMacSaHashInfo(V, gMacSaLkpResult_macSaHashKeyHitIndex_f, &mac_sa_info);
            in.type = DRV_ACC_TYPE_LOOKUP;
            in.tbl_id = DsFibHost0MacHashKey_t;
            in.index =  value;
            in.op_type = DRV_ACC_OP_BY_INDEX;
            drv_acc_get_hash_module(lchip, in.tbl_id, &in.module);
            CTC_ERROR_RETURN(drv_acc_api(lchip, &in, &out));
            drv_get_field(lchip, DsFibHost0MacHashKey_t, DsFibHost0MacHashKey_dsAdIndex_f, out.data, &ad_index);
            DIAG_INFO_CHAR(pos, "key-name", "DsFibHost0MacHashKey")
            DIAG_INFO_UINT32(pos, "key-index", value)
            DIAG_INFO_CHAR(pos, "ad-name", "DsMac")
            DIAG_INFO_UINT32(pos, "ad-index", ad_index)
        }
        else if (GetDbgIpeMacLearningInfo(V, macSaDefaultEntryValid_f, &mac_learn_info))
        {
            DIAG_INFO_CHAR(pos, "macsa-lookup-result", DIAG_LOOKUP_DEFAULT)
        }
        else
        {
            DIAG_INFO_CHAR(pos, "macsa-lookup-result", DIAG_LOOKUP_HIT_NONE)
        }

        if (GetDbgIpeMacLearningInfo(V, learningEn_f, &mac_learn_info))
        {
            DIAG_INFO_CHAR(pos, "learning-mode", (GetDbgIpeMacLearningInfo(V, learningType_f, &mac_learn_info) ? "HW" : "SW"))
            DIAG_INFO_UINT32(pos, "learning-fid", fid)
            value = GetDbgIpeMacLearningInfo(V, learningSrcPort_f, &mac_learn_info);
            if (!GetDbgIpeMacLearningInfo(V, learningUseGlobalSrcPort_f, &mac_learn_info))
            {
                DIAG_INFO_UINT32(pos, "learning-logic-port", value)
            }
            else
            {
                DIAG_INFO_UINT32(pos, "learning-global-port", SYS_MAP_DRV_GPORT_TO_CTC_GPORT(value))
            }
            DIAG_INFO_UINT32(pos, "aging-ptr", GetDbgIpeMacLearningInfo(V, agingIndex_f, &mac_learn_info))
        }
        DIAG_INFO_CHAR(pos, "do-learning",(GetDbgIpeFwdProcessInfo(V, valid_f, &fwd_proc_info)&&GetDbgIpeFwdProcessInfo(V, doLearningOperation_f, &fwd_proc_info))?DIAG_YES:DIAG_NO)
    }
    /* Drop Process */
    _sys_tmm_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeMacLearningInfo(V, discard_f, &mac_learn_info),
                                          GetDbgIpeMacLearningInfo(V, discardType_f, &mac_learn_info));
    /* Exception Process */
    _sys_tmm_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeMacLearningInfo(V, exceptionEn_f, &mac_learn_info),
                                               GetDbgIpeMacLearningInfo(V, exceptionIndex_f, &mac_learn_info),
                                               GetDbgIpeMacLearningInfo(V, exceptionSubIndex_f, &mac_learn_info));
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_route_tbl_id(uint8 lchip, uint32 pri_valid, uint32 tcam_group_index, uint32 key_type, uint32* key_id, uint32* ad_id)
{
    uint32 cmd = 0;
    LpmTcamCtl_m lpm_tcam_ctl;

    sal_memset( &lpm_tcam_ctl, 0, sizeof(LpmTcamCtl_m));
    cmd = DRV_IOR(LpmTcamCtl_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &lpm_tcam_ctl));

    if (SYS_TMM_DIAG_L3DA_TYPE_IPV4UC == key_type)
    {
        *key_id = pri_valid ? DsLpmTcamIpv4HalfKey_t : DsLpmTcamIpv4DaPubHalfKey_t;
        *ad_id = pri_valid ? DsLpmTcamIpv4HalfKeyAd_t : DsLpmTcamIpv4DaPubHalfKeyAd_t;
    }
    else if (SYS_TMM_DIAG_L3DA_TYPE_IPV6UC == key_type && !GetLpmTcamCtl(V, tcamGroupConfig_0_ipv6Lookup64Prefix_f + tcam_group_index, &lpm_tcam_ctl))
    {
        *key_id = pri_valid ? DsLpmTcamIpv6DoubleKey0_t : DsLpmTcamIpv6DaPubDoubleKey0_t;
        *ad_id = pri_valid ? DsLpmTcamIpv6DoubleKey0Ad_t : DsLpmTcamIpv6DaPubDoubleKey0Ad_t;
    }
    else if (SYS_TMM_DIAG_L3DA_TYPE_IPV6UC == key_type && GetLpmTcamCtl(V, tcamGroupConfig_0_ipv6Lookup64Prefix_f + tcam_group_index, &lpm_tcam_ctl))
    {
        *key_id = pri_valid ? DsLpmTcamIpv6SingleKey_t : DsLpmTcamIpv6DaPubSingleKey_t;
        *ad_id = pri_valid ? DsLpmTcamIpv6SingleKeyAd_t : DsLpmTcamIpv6DaPubSingleKeyAd_t;
    }

    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_map_ipuc_key_index(uint8 lchip, uint32 tbl_id, uint32 key_index, uint32* mapped_key_idx, uint32* mapped_ad_idx)
{
    uint32 entry_num = DRV_TCAM_KEY_SIZE(lchip, tbl_id) / DRV_LPM_KEY_BYTES_PER_ENTRY;
#if (SDK_WORK_PLATFORM == 0)
    uint8 block_num = 0;
    uint8 blk_id = 0;
    uint16 blk_offset = 0;
    uint32 local_index = 0;
    uint32 blk_size = 0;

    block_num = (key_index >> DIAG_LPM_TCAM_LOCAL_BIT_LEN)&0x3 ;
    local_index = key_index & ((1<<DIAG_LPM_TCAM_LOCAL_BIT_LEN )-1);

    blk_size = ((block_num <= 1) ? (DIAG_LPM_TCAM_MAX_ENTRY_NUM/2) : (DIAG_LPM_TCAM_MAX_ENTRY_NUM));
    blk_id = local_index /blk_size + block_num * 2;
    blk_offset = local_index - local_index / blk_size * blk_size;

    *mapped_key_idx = (DRV_TCAM_START_INDEX(lchip, DsLpmTcamIpv4HalfKey_t, blk_id) +  blk_offset)/(entry_num ? entry_num : 1) ;
    *mapped_ad_idx = DRV_TCAM_START_INDEX(lchip, DsLpmTcamIpv4HalfKeyAd_t, blk_id) +  blk_offset;
#endif

#if (SDK_WORK_PLATFORM == 1)
    *mapped_key_idx = key_index/(entry_num ? entry_num : 1);
    *mapped_ad_idx = key_index;
#endif
    return CTC_E_NONE;

}

STATIC int32
_sys_tmm_diag_pkt_trace_get_ipe_route_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    uint32 cmd = 0;
    uint32 value = 0;
    uint8 index = 0;
    uint8  step = 0;
    uint32 key_index = 0;
    uint32 grp0_valid[6] = {0};
    uint32 grp0_index[6] = {0};
    uint32 grp1_valid[6] = {0};
    uint32 grp1_index[6] = {0};
    char* key_name = "Unknown..";
    char* ad_name = "Unknown..";
    DbgFibLkpEnginel3DaHashInfo_m l3_da_info;
    DbgFibLkpEnginel3SaHashInfo_m l3_sa_info;
    DbgFibLkpEngineHostUrpfHashInfo_m urpf_info;
    DbgLpmTcamEngineResult0Info_m lpm_res0;
    DbgLpmTcamEngineResult1Info_m lpm_res1;
    DbgIpeIpRoutingInfo_m routing_info;
    DbgFibLkpEngineFibHashInfo_m fib_info;
    char *sys_diag_fib_l3da_key[] = {
        "IPV4UCAST",    "IPV6UCAST",    "IPV4MCAST",    "IPV6MCAST",
        "FCOE",         "TRILLUCAST",   "TRILLMCAST",   "RESERVED"};

    sal_memset(&l3_da_info, 0, sizeof(l3_da_info));
    cmd = DRV_IOR(DbgFibLkpEnginel3DaHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &l3_da_info));
    sal_memset(&l3_sa_info, 0, sizeof(l3_sa_info));
    cmd = DRV_IOR(DbgFibLkpEnginel3SaHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &l3_sa_info));
    sal_memset(&urpf_info, 0, sizeof(urpf_info));
    cmd = DRV_IOR(DbgFibLkpEngineHostUrpfHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &urpf_info));
    sal_memset(&routing_info, 0, sizeof(routing_info));
    cmd = DRV_IOR(DbgIpeIpRoutingInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &routing_info));
    sal_memset(&lpm_res0, 0, sizeof(lpm_res0));
    cmd = DRV_IOR(DbgLpmTcamEngineResult0Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &lpm_res0));
    sal_memset(&fib_info, 0, sizeof(fib_info));
    cmd = DRV_IOR(DbgFibLkpEngineFibHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &fib_info));
    step = DbgLpmTcamEngineResult0Info_gTcamGroup_1_lookupResultValid_f - DbgLpmTcamEngineResult0Info_gTcamGroup_0_lookupResultValid_f;
    for (index = 0; index < 6; index++)
    {
        DRV_IOR_FIELD(lchip, DbgLpmTcamEngineResult0Info_t, DbgLpmTcamEngineResult0Info_gTcamGroup_0_lookupResultValid_f+index*step,
            &grp0_valid[index], &lpm_res0);

        DRV_IOR_FIELD(lchip, DbgLpmTcamEngineResult0Info_t, DbgLpmTcamEngineResult0Info_gTcamGroup_0_tcamHitIndex_f+index*step,
            &grp0_index[index], &lpm_res0);
    }
    sal_memset(&lpm_res1, 0, sizeof(lpm_res1));
    cmd = DRV_IOR(DbgLpmTcamEngineResult1Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &lpm_res1));
    step = DbgLpmTcamEngineResult1Info_gTcamGroup_1_lookupResultValid_f - DbgLpmTcamEngineResult1Info_gTcamGroup_0_lookupResultValid_f;
    for (index = 0; index < 6; index++)
    {
        DRV_IOR_FIELD(lchip, DbgLpmTcamEngineResult1Info_t, DbgLpmTcamEngineResult1Info_gTcamGroup_0_lookupResultValid_f+index*step,
            &grp1_valid[index], &lpm_res1);

        DRV_IOR_FIELD(lchip, DbgLpmTcamEngineResult1Info_t, DbgLpmTcamEngineResult1Info_gTcamGroup_0_tcamHitIndex_f+index*step,
            &grp1_index[index], &lpm_res1);
    }

    if (!GetDbgIpeIpRoutingInfo(V, valid_f, &routing_info))
    {
        return CTC_E_NONE;
    }

    if (!(GetDbgFibLkpEnginel3DaHashInfo(V, l3DaLookupEn_f, &l3_da_info)
        || GetDbgFibLkpEnginel3SaHashInfo(V, l3SaLookupEn_f, &l3_sa_info)))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "Layer3 Routing")
    if (GetDbgFibLkpEnginel3DaHashInfo(V, l3DaLookupEn_f, &l3_da_info))
    {
        if (GetDbgFibLkpEngineFibHashInfo(V, valid_f, &fib_info) && GetDbgFibLkpEngineFibHashInfo(V, l3DaLookupEn_f, &fib_info))
        {
            DIAG_INFO_CHAR(pos, "ipda-lookup", DIAG_ENABLE)
            DIAG_INFO_CHAR(pos, "key-type", STR_ARRAY(sys_diag_fib_l3da_key,GetDbgFibLkpEngineFibHashInfo(V, l3DaKeyType_f, &fib_info)))
        }
        if (GetDbgIpeIpRoutingInfo(V, ipHeaderError_f, &routing_info))
        {
            DIAG_INFO_CHAR(pos, "ipda-lookup-result", "IP-HEADER-ERROR")
        }
        else if (GetDbgIpeIpRoutingInfo(V, ipDaResultValid_f, &routing_info))
        {
            if (GetDbgFibLkpEnginel3DaHashInfo(V, hostHashFirstL3DaResultValid_f, &l3_da_info)
                || GetDbgFibLkpEnginel3DaHashInfo(V, hostHashSecondDaResultValid_f, &l3_da_info))
            {
                DIAG_INFO_CHAR(pos, "ipda-lookup-result", "HIT-HASH")
                DIAG_INFO_UINT32(pos, "vrf-id", GetDbgFibLkpEnginel3DaHashInfo(V, vrfId_f, &l3_da_info))

                value = GetDbgFibLkpEnginel3DaHashInfo(V, l3DaKeyType_f, &l3_da_info);
                if ((SYS_TMM_DIAG_L3DA_TYPE_IPV4UC == value) ||
                    (SYS_TMM_DIAG_L3DA_TYPE_IPV4MC == value))/* FIBDAKEYTYPE_IPV4UCAST or FIBDAKEYTYPE_IPV4MCAST */
                {
                    key_name = (GetDbgFibLkpEnginel3DaHashInfo(V, natDaValid_f, &l3_da_info) 
                                && GetDbgFibLkpEnginel3DaHashInfo(V, hostHashSecondDaResultValid_f, &l3_da_info)) ? "DsFibHost1Ipv4NatDaPortHashKey" : "DsFibHost0Ipv4HashKey";
                    ad_name = "DsIpDa";
                }
                else if (SYS_TMM_DIAG_L3DA_TYPE_IPV6UC == value)/* FIBDAKEYTYPE_IPV6UCAST */
                {
                    key_name = "DsFibHost0Ipv6UcastHashKey";
                    ad_name = "DsIpDa";
                }
                else if (SYS_TMM_DIAG_L3DA_TYPE_IPV6MC == value)/* FIBDAKEYTYPE_IPV6MCAST */
                {
                    key_name = "DsFibHost0MacIpv6McastHashKey";
                    ad_name = "DsIpDa";
                }
                else if (SYS_TMM_DIAG_L3DA_TYPE_TRILLUC == value)
                {
                    key_name = "DsFibHost0TrillHashKey";
                    ad_name = "DsTrillDa";
                }
                else if (SYS_TMM_DIAG_L3DA_TYPE_TRILLMC == value)
                {
                    key_name = "DsFibHost1TrillMcastVlanHashKey";
                    ad_name = "DsTrillDa";
                }
                else if (SYS_TMM_DIAG_L3DA_TYPE_FCOE== value)
                {
                    key_name = "DsFibHost0FcoeHashKey";
                    ad_name = "DsFcoeDa";
                }
                else
                {
                    key_name = "Unknown..";
                    ad_name = "Unknown..";
                }

                DIAG_INFO_CHAR(pos, "key-name", key_name)
                value = GetDbgFibLkpEnginel3DaHashInfo(V, hostHashFirstL3DaResultValid_f, &l3_da_info)
                        ? GetDbgFibLkpEnginel3DaHashInfo(V, hostHashFirstL3DaKeyIndex_f, &l3_da_info)
                        : GetDbgFibLkpEnginel3DaHashInfo(V, hostHashSecondDaKeyIndex_f, &l3_da_info);
                DIAG_INFO_UINT32(pos, "key-index", value)
                DIAG_INFO_CHAR(pos, "ad-name", ad_name)
            }
            else if (GetDbgFibLkpEnginel3DaHashInfo(V, l3DaTcamLookup1PrivateResultValid_f, &l3_da_info)
                || GetDbgFibLkpEnginel3DaHashInfo(V, l3DaTcamLookup1PublicResultValid_f, &l3_da_info)
                || GetDbgFibLkpEnginel3DaHashInfo(V, l3DaTcamLookup2PrivateResultValid_f, &l3_da_info)
                || GetDbgFibLkpEnginel3DaHashInfo(V, l3DaTcamLookup2PublicResultValid_f, &l3_da_info))
            {
                char str[64] = {0};
                uint32 key_table_id = 0;
                uint32 ad_table_id = 0;
                uint32 mapped_key_index = 0;
                uint32 mapped_ad_index = 0;
                DIAG_INFO_CHAR(pos, "ipda-lookup-result", "HIT-LPM-TCAM")

                if (GetDbgFibLkpEnginel3DaHashInfo(V, l3DaTcamLookup1PrivateResultValid_f, &l3_da_info))
                {
                    for (index = 0; index < 6; index++)
                    {
                        if (!grp0_valid[index])
                        {
                            continue;
                        }
                        key_index = grp0_index[index];
                        sal_sprintf(str, "lookup1-private-block-%d", index);
                        DIAG_INFO_CHAR(pos, "tcam-key", str)
                        break;
                    }
                }

                if (GetDbgFibLkpEnginel3DaHashInfo(V, l3DaTcamLookup1PublicResultValid_f, &l3_da_info))
                {
                    for (index = 0; index < 6; index++)
                    {
                        if (!grp0_valid[index])
                        {
                            continue;
                        }
                        key_index = grp0_index[index];
                        sal_sprintf(str, "lookup1-public-block-%d", index);
                        DIAG_INFO_CHAR(pos, "tcam-key", str)
                        break;
                    }
                }
                if (GetDbgFibLkpEnginel3DaHashInfo(V, l3DaTcamLookup2PrivateResultValid_f, &l3_da_info))
                {
                    for (index = 0; index < 6; index++)
                    {
                        if (!grp1_valid[index])
                        {
                            continue;
                        }
                        key_index = grp1_index[index];
                        sal_sprintf(str, "lookup2-private-block-%d", index);
                        DIAG_INFO_CHAR(pos, "tcam-key", str)
                        break;
                    }
                }
                if (GetDbgFibLkpEnginel3DaHashInfo(V, l3DaTcamLookup2PublicResultValid_f, &l3_da_info))
                {
                    for (index = 0; index < 6; index++)
                    {
                        if (!grp1_valid[index])
                        {
                            continue;
                        }
                        key_index = grp1_index[index];
                        sal_sprintf(str, "lookup2-public-block-%d", index);
                        DIAG_INFO_CHAR(pos, "tcam-key", str)
                        break;
                    }
                }

                value = GetDbgFibLkpEnginel3DaHashInfo(V, l3DaKeyType_f, &l3_da_info);
                CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_route_tbl_id(lchip,
                                        GetDbgFibLkpEnginel3DaHashInfo(V, l3DaTcamLookup1PrivateResultValid_f, &l3_da_info),
                                        index, value, &key_table_id, &ad_table_id));

                if (SYS_TMM_DIAG_L3DA_TYPE_IPV4UC == value)
                {
                    key_name = DRV_TABLE_NAME(lchip, key_table_id);
                    ad_name = DRV_TABLE_NAME(lchip, ad_table_id);
                    _sys_tmm_diag_pkt_trace_map_ipuc_key_index(lchip, key_table_id, key_index, &mapped_key_index, &mapped_ad_index);
                }
                else if (SYS_TMM_DIAG_L3DA_TYPE_IPV6UC == value)
                {
                    key_name = DRV_TABLE_NAME(lchip, key_table_id);
                    ad_name = DRV_TABLE_NAME(lchip, ad_table_id);
                    _sys_tmm_diag_pkt_trace_map_ipuc_key_index(lchip, key_table_id, key_index, &mapped_key_index, &mapped_ad_index);
                }
                DIAG_INFO_UINT32(pos, "spec-tcam-index", key_index)
                DIAG_INFO_CHAR(pos, "key-name", key_name)
                DIAG_INFO_UINT32(pos, "key-index", mapped_key_index)
                DIAG_INFO_CHAR(pos, "tcam-ad-name", ad_name)
                DIAG_INFO_UINT32(pos, "tcam-ad-index", mapped_ad_index)
                DIAG_INFO_CHAR(pos, "ad-name", "DsIpDa")
            }
            DIAG_INFO_UINT32(pos, "ad-index", GetDbgFibLkpEnginel3DaHashInfo(V, l3DaAdindexForDebug_f, &l3_da_info))
        }
        else
        {
            DIAG_INFO_CHAR(pos, "ipda-lookup-result", DIAG_LOOKUP_HIT_NONE)
        }
    }

    if (GetDbgFibLkpEnginel3SaHashInfo(V, l3SaLookupEn_f, &l3_sa_info))
    {
        if (GetDbgIpeIpRoutingInfo(V, ipSaResultValid_f, &routing_info))
        {
            char* result = "null";


            value = GetDbgFibLkpEnginel3SaHashInfo(V, l3SaKeyType_f, &l3_sa_info);
            if (value == SYS_TMM_DIAG_L3SA_TYPE_IPV4NATSA)
            {
                if (GetDbgFibLkpEnginel3SaHashInfo(V, hostHashFirstSaNatTcamResultValid_f, &l3_sa_info))
                {
                    result = "HIT-LPM-TCAM-IPv4-NAT";
                    key_name = "DsLpmTcamIpv4NatDoubleKey";
                    key_index = GetDbgFibLkpEnginel3SaHashInfo(V, hostHashFirstSaTcamHitIndex_f, &l3_sa_info);
                }
                else if (GetDbgFibLkpEnginel3SaHashInfo(V, l3SaResultValid_f, &l3_sa_info))
                {
                    result = "HIT-HASH-IPv4-NAT";
                    key_name = "DsFibHost1Ipv4NatSaPortHashKey";
                    key_index = GetDbgFibLkpEnginel3SaHashInfo(V, hostHashSecondSaKeyIndex_f, &l3_sa_info);
                }
            }
            else if (value == SYS_TMM_DIAG_L3SA_TYPE_IPV6NATSA)
            {
                if (GetDbgFibLkpEnginel3SaHashInfo(V, hostHashFirstSaNatTcamResultValid_f, &l3_sa_info))
                {
                    result = "HIT-LPM-TCAM-IPv6-NAT";
                    key_name = "DsLpmTcamIpv6DoubleKey0";
                    key_index = GetDbgFibLkpEnginel3SaHashInfo(V, hostHashFirstSaTcamHitIndex_f, &l3_sa_info);
                }
                else if (GetDbgFibLkpEnginel3SaHashInfo(V, l3SaResultValid_f, &l3_sa_info))
                {
                    result = "HIT-HASH-IPv6-NAT";
                    key_name = "DsFibHost1Ipv6NatSaPortHashKey";
                    key_index = GetDbgFibLkpEnginel3SaHashInfo(V, hostHashSecondSaKeyIndex_f, &l3_sa_info);
                }
            }
            else if (value == SYS_TMM_DIAG_L3SA_TYPE_IPV4RPF)
            {
                if (GetDbgFibLkpEnginel3SaHashInfo(V, hostHashFirstSaRpfTcamResultValid_f, &l3_sa_info))
                {
                    result = "HIT-LPM-TCAM-IPv4-RPF";
                    key_name = "DsLpmTcamIpv4HalfKey";
                    key_index = GetDbgFibLkpEnginel3SaHashInfo(V, hostHashFirstSaTcamHitIndex_f, &l3_sa_info);
                }
                else if (GetDbgFibLkpEnginel3SaHashInfo(V, l3SaResultValid_f, &l3_sa_info))
                {
                    result = "HIT-HASH-IPv4-RPF";
                    key_name = "DsFibHost0Ipv4HashKey";
                    key_index = GetDbgFibLkpEngineHostUrpfHashInfo(V, hostUrpfHashHitIndex_f, &urpf_info);
                }
            }
            else if (value == SYS_TMM_DIAG_L3SA_TYPE_IPV6RPF)
            {
                if (GetDbgFibLkpEnginel3SaHashInfo(V, hostHashFirstSaRpfTcamResultValid_f, &l3_sa_info))
                {
                    result = "HIT-LPM-TCAM-IPv6-RPF";
                    key_name = "DsLpmTcamIpv6DoubleKey0";
                    key_index = GetDbgFibLkpEnginel3SaHashInfo(V, hostHashFirstSaTcamHitIndex_f, &l3_sa_info);
                }
                else if (GetDbgFibLkpEnginel3SaHashInfo(V, l3SaResultValid_f, &l3_sa_info))
                {
                    result = "HIT-HASH-IPv6-RPF";
                    key_name = "DsFibHost0Ipv6UcastHashKey";
                    key_index = GetDbgFibLkpEnginel3SaHashInfo(V, hostHashSecondSaKeyIndex_f, &l3_sa_info);
                }
            }
            else if (value == SYS_TMM_DIAG_L3SA_TYPE_FCOERPF)
            {
                result = "HIT-HASH-FCoE-RPF";
                key_name = "DsFibHost1FcoeRpfHashKey";
                key_index = GetDbgFibLkpEnginel3SaHashInfo(V, hostHashSecondSaKeyIndex_f, &l3_sa_info);
            }
            DIAG_INFO_CHAR(pos, "ipsa-lookup-result", result)
            DIAG_INFO_CHAR(pos, "key-name", key_name)
            DIAG_INFO_UINT32(pos, "key-index", key_index)
            DIAG_INFO_UINT32(pos, "ad-index", GetDbgFibLkpEnginel3SaHashInfo(V, l3SaAdindexForDebug_f, &l3_sa_info))
        }
        else
        {
            DIAG_INFO_CHAR(pos, "ipsa-lookup-result", DIAG_LOOKUP_HIT_NONE)
        }
    }

    if (GetDbgIpeIpRoutingInfo(V, routingEscape_f, &routing_info))
    {
        DIAG_INFO_CHAR(pos, "routing-escape", "ENABLE")
    }

    if(!GetDbgIpeIpRoutingInfo(V, valid_f, &routing_info))
    {
        return CTC_E_NONE;
    }
    /* Drop Process */
    _sys_tmm_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeIpRoutingInfo(V, discard_f, &routing_info),
                                          GetDbgIpeIpRoutingInfo(V, discardType_f, &routing_info));
    /* Exception Process */
    _sys_tmm_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeIpRoutingInfo(V, exceptionEn_f, &routing_info),
                                               GetDbgIpeIpRoutingInfo(V, exceptionIndex_f, &routing_info),
                                               GetDbgIpeIpRoutingInfo(V, exceptionSubIndex_f, &routing_info));
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_lag_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    IpeToLagEngineInput_m ipe_lag_input;
    LagEngineOutput_m  lag_ouput;
    DbgLagEngineInfo_m lag_info;

    sal_memset(&lag_info, 0, sizeof(DbgLagEngineInfo_m));
    cmd = DRV_IOR(DbgLagEngineInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &lag_info));
    GetDbgLagEngineInfo(A, lagEngineInput_f, &lag_info, &ipe_lag_input);
    GetDbgLagEngineInfo(A, lagEngineOutput_f, &lag_info, &lag_ouput);

    if (!GetDbgLagEngineInfo(V, valid_f, &lag_info))
    {
        return CTC_E_NONE;
    }

    if (GetDbgLagEngineInfo(V, sgmacLagEnable_f, &lag_info))
    {
        DIAG_INFO_CHAR(pos, "Linkagg Process", "stacking-trunk")
        DIAG_INFO_UINT32(pos, "cFlexSgGroupSel", GetIpeToLagEngineInput(V, cFlexFwdSgGroupSel_f, &ipe_lag_input))
        DIAG_INFO_UINT32(pos, "cFlexLagHash", GetIpeToLagEngineInput(V, cFlexLagHash_f, &ipe_lag_input))
        DIAG_INFO_UINT32(pos, "stackingDiscard", GetLagEngineOutput(V, stackingDiscard_f, &lag_ouput))
        DIAG_INFO_UINT32(pos, "dest-trunk-id", GetLagEngineOutput(V, destSgmacGroupId_f, &lag_ouput))

        if (GetDbgLagEngineInfo(V, dbgCflexSlbEn_f, &lag_info))
        {
            DIAG_INFO_CHAR(pos, "trunk-mode", "STATIC")
            DIAG_INFO_UINT32(pos, "hash-value", GetDbgLagEngineInfo(V, debugCflexHash_f, &lag_info))
        }
        else if (GetDbgLagEngineInfo(V, dbgCflexRrEn_f, &lag_info))
        {
            DIAG_INFO_CHAR(pos, "trunk-mode", "RR")
        }
        else if (GetDbgLagEngineInfo(V, dbgCflexDlbEn_f, &lag_info))
        {
            DIAG_INFO_CHAR(pos, "trunk-mode", "DLB")
            DIAG_INFO_UINT32(pos, "hash-value", GetDbgLagEngineInfo(V, debugCflexHash_f, &lag_info))
        }
        else if (GetDbgLagEngineInfo(V, dbgCflexRhEn_f, &lag_info))
        {
            DIAG_INFO_CHAR(pos, "trunk-mode", "RH")
            DIAG_INFO_UINT32(pos, "hash-value", GetDbgLagEngineInfo(V, debugCflexHash_f, &lag_info))
        }

        if (GetDbgLagEngineInfo(V, dbgCflexLshEn_f, &lag_info))
        {
            DIAG_INFO_CHAR(pos, "link self healing", "ENABLE")
            DIAG_INFO_UINT32(pos, "lsh-hash-value", GetDbgLagEngineInfo(V, debugCflexLshHash_f, &lag_info))
        }

        p_rslt->tid = GetLagEngineOutput(V, destSgmacGroupId_f, &lag_ouput);
        p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_TID;
    }
    else if (GetDbgLagEngineInfo(V, chanLagEnable_f, &lag_info) || GetDbgLagEngineInfo(V, portLagEnable_f, &lag_info))
    {
        if (GetDbgLagEngineInfo(V, chanLagEnable_f, &lag_info))
        {
            DIAG_INFO_CHAR(pos, "Linkagg Process", "channel-linkagg")
        }
        else
        {
            DIAG_INFO_CHAR(pos, "Linkagg Process", "port-linkagg")
        }

        DIAG_INFO_UINT32(pos, "linkagg-id", GetIpeToLagEngineInput(V, destMap_f, &ipe_lag_input) & CTC_LINKAGGID_MASK)

        if (GetDbgLagEngineInfo(V, dbgPLagSlbEn_f, &lag_info))
        {
            DIAG_INFO_CHAR(pos, "linkagg-mode", "STATIC")
            DIAG_INFO_UINT32(pos, "hash-value", GetDbgLagEngineInfo(V, debugPortLagHash_f, &lag_info))
        }
        else if (GetDbgLagEngineInfo(V, dbgPLagRrEn_f, &lag_info))
        {
            DIAG_INFO_CHAR(pos, "linkagg-mode", "RR")
        }
        else if (GetDbgLagEngineInfo(V, dbgPLagDlbEn_f, &lag_info))
        {
            DIAG_INFO_CHAR(pos, "linkagg-mode", "DLB")
            DIAG_INFO_UINT32(pos, "hash-value", GetDbgLagEngineInfo(V, debugPortLagHash_f, &lag_info))
        }
        else if (GetDbgLagEngineInfo(V, dbgPLagRhEn_f, &lag_info))
        {
            DIAG_INFO_CHAR(pos, "linkagg-mode", "RH")
            DIAG_INFO_UINT32(pos, "hash-value", GetDbgLagEngineInfo(V, debugPortLagHash_f, &lag_info))
        }
        else if (GetDbgLagEngineInfo(V, dbgPLagLmpfEn_f, &lag_info))
        {
            DIAG_INFO_CHAR(pos, "linkagg-mode", "LMPF")
            DIAG_INFO_UINT32(pos, "hash-value", GetDbgLagEngineInfo(V, debugPortLagHash_f, &lag_info))
        }

        if (GetDbgLagEngineInfo(V, dbgPLagLshEn_f, &lag_info))
        {
            DIAG_INFO_CHAR(pos, "link self healing", "ENABLE")
            DIAG_INFO_UINT32(pos, "lsh-hash-value", GetDbgLagEngineInfo(V, debugPortLagLshHash_f, &lag_info))
        }

        if (GetDbgLagEngineInfo(V, antFlowEn_f, &lag_info))
        {
            DIAG_INFO_CHAR(pos, "antFlowEn", "ENABLE")
            DIAG_INFO_UINT32(pos, "active", GetDbgLagEngineInfo(V, antFlowActive_f, &lag_info))
            DIAG_INFO_UINT32(pos, "link-state", GetDbgLagEngineInfo(V, antFlowLinkState_f, &lag_info))
            DIAG_INFO_UINT32(pos, "path-valid", GetDbgLagEngineInfo(V, antFlowPathValid_f, &lag_info))
            DIAG_INFO_UINT32(pos, "agingPtr", GetDbgLagEngineInfo(V, agingPtr_f, &lag_ouput))
            DIAG_INFO_U32_HEX(pos, "record-info", GetDbgLagEngineInfo(V, antFlowRecordInfo_f, &lag_info))
//              DIAG_INFO_UINT32(pos, "srv-hash-value", GetDbgLagEngineInfo(V, antFlowHash_f, &lag_info))
        }

        p_rslt->tid = GetIpeToLagEngineInput(V, destMap_f, &ipe_lag_input) & CTC_LINKAGGID_MASK;
        p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_TID;
    }

    if (GetLagEngineOutput(V, destChannelIdValid_f, &lag_ouput))
    {
        DIAG_INFO_UINT32(pos, "dest-slice", GetLagEngineOutput(V, destSliceId_f, &lag_ouput))
        DIAG_INFO_UINT32(pos, "dest-channel", GetLagEngineOutput(V, destChannelId_f, &lag_ouput))
    }
    DIAG_INFO_U32_HEX(pos, "dest-map", GetLagEngineOutput(V, updateDestMap_f, &lag_ouput))

    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_ipe_phb_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    DbgIpePerHopBehaviorInfo_m dbg_phb_info;
    char *sys_diag_color[] = {"None", "Red", "Yellow", "Green"};

    /*phb process*/
    sal_memset(&dbg_phb_info, 0, sizeof(DbgIpePerHopBehaviorInfo_m));
    cmd = DRV_IOR(DbgIpePerHopBehaviorInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &dbg_phb_info));

    if(GetDbgIpePerHopBehaviorInfo(V, valid_f, &dbg_phb_info))
    {
        p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
        DIAG_INFO_NONE(pos, "Per-hop Behavior")
        DIAG_INFO_CHAR(pos, "phb-color", STR_ARRAY(sys_diag_color,GetDbgIpePerHopBehaviorInfo(V, color_f, &dbg_phb_info)))
        DIAG_INFO_UINT32(pos, "phb-prio", GetDbgIpePerHopBehaviorInfo(V, prio_f, &dbg_phb_info))
        DIAG_INFO_UINT32(pos, "phb-classified-cfi", GetDbgIpePerHopBehaviorInfo(V, classifiedCfi_f, &dbg_phb_info))
        DIAG_INFO_UINT32(pos, "phb-classified-cos", GetDbgIpePerHopBehaviorInfo(V, classifiedCos_f, &dbg_phb_info))
        DIAG_INFO_UINT32(pos, "phb-classified-dscp", GetDbgIpePerHopBehaviorInfo(V, classifiedDscp_f, &dbg_phb_info))
        DIAG_INFO_UINT32(pos, "phb-classified-tc", GetDbgIpePerHopBehaviorInfo(V, classifiedTc_f, &dbg_phb_info))
        if (GetDbgIpePerHopBehaviorInfo(V, srcDscpValid_f, &dbg_phb_info))
        {
            DIAG_INFO_UINT32(pos, "phb-src-dscp",  GetDbgIpePerHopBehaviorInfo(V, srcDscp_f, &dbg_phb_info))
        }
    }

    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_ipe_oam_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8  idx = 0;
    uint32 value = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    char* lookup_result[] = {"ETHER", "BFD", "TP", "Section"};
    char* key_name[] = {"DsOamEthHashKey", "DsOamBfdHashKey",
                         "DsOamMplsLabelHashKey", "DsOamMplsSectionHashKey"};
    char *sys_diag_color[] = {"None", "Red", "Yellow", "Green"};
    DbgOamHashEngineFromIpeOam0Info_m oam0_info;
    DbgOamHashEngineFromIpeOam1Info_m oam1_info;
    DbgOamHashEngineFromIpeOam2Info_m oam2_info;
    DbgIpeLkpMgrInfo_m lkp_mgr_info;
    DbgIpeOamInfo_m ipe_oam_info;
    uint8 key_type[3] = {0};
    uint8 hash_valid[3] = {0};
    uint8 confict[3] = {0};
    uint32 key_index[3] = {0};
    uint8 hash_resultValid[3] = {0};

    sal_memset(&oam0_info, 0, sizeof(oam0_info));
    cmd = DRV_IOR(DbgOamHashEngineFromIpeOam0Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &oam0_info));
    sal_memset(&oam1_info, 0, sizeof(oam1_info));
    cmd = DRV_IOR(DbgOamHashEngineFromIpeOam1Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &oam1_info));
    sal_memset(&oam2_info, 0, sizeof(oam2_info));
    cmd = DRV_IOR(DbgOamHashEngineFromIpeOam2Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &oam2_info));
    sal_memset(&lkp_mgr_info, 0, sizeof(lkp_mgr_info));
    cmd = DRV_IOR(DbgIpeLkpMgrInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &lkp_mgr_info));
    sal_memset(&ipe_oam_info, 0, sizeof(ipe_oam_info));
    cmd = DRV_IOR(DbgIpeOamInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ipe_oam_info));

    key_type[0] = GetDbgIpeLkpMgrInfo(V, ingressOamKeyType0_f, &lkp_mgr_info);
    key_type[1] = GetDbgIpeLkpMgrInfo(V, ingressOamKeyType1_f, &lkp_mgr_info);
    key_type[2] = GetDbgIpeLkpMgrInfo(V, ingressOamKeyType2_f, &lkp_mgr_info);

    hash_resultValid[0] = GetDbgOamHashEngineFromIpeOam0Info(V, resultValid_f, &oam0_info);
    confict[0] = GetDbgOamHashEngineFromIpeOam0Info(V, hashConflict_f, &oam0_info);
    key_index[0] = GetDbgOamHashEngineFromIpeOam0Info(V, keyIndex_f, &oam0_info);
    hash_valid[0] = GetDbgOamHashEngineFromIpeOam0Info(V, valid_f, &oam0_info);

    hash_resultValid[1] = GetDbgOamHashEngineFromIpeOam1Info(V, resultValid_f, &oam1_info);
    confict[1] = GetDbgOamHashEngineFromIpeOam1Info(V, hashConflict_f, &oam1_info);
    key_index[1] = GetDbgOamHashEngineFromIpeOam1Info(V, keyIndex_f, &oam1_info);
    hash_valid[1] = GetDbgOamHashEngineFromIpeOam1Info(V, valid_f, &oam1_info);

    hash_resultValid[2] = GetDbgOamHashEngineFromIpeOam2Info(V, resultValid_f, &oam2_info);
    confict[2] = GetDbgOamHashEngineFromIpeOam2Info(V, hashConflict_f, &oam2_info);
    key_index[2] = GetDbgOamHashEngineFromIpeOam2Info(V, keyIndex_f, &oam2_info);
    hash_valid[2] = GetDbgOamHashEngineFromIpeOam2Info(V, valid_f, &oam2_info);

    if (!GetDbgIpeOamInfo(V, valid_f, &ipe_oam_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "IPE OAM")
    if (key_type[0] || key_type[1] || key_type[2])
    {
        char str[64] = {0};
        DIAG_INFO_CHAR(pos, "dm-en", GetDbgIpeOamInfo(V, dmEn_f, &ipe_oam_info)? DIAG_ENABLE: DIAG_DISABLE)
        cmd = DRV_IOR(IpeOamCtl_t, IpeOamCtl_oamPriMapEn_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
        if (value)
        {
            DIAG_INFO_UINT32(pos, "prio", GetDbgIpeOamInfo(V, prio_f, &ipe_oam_info))
            DIAG_INFO_CHAR(pos, "color", STR_ARRAY(sys_diag_color,GetDbgIpeOamInfo(V, color_f, &ipe_oam_info)))
        }
        for (idx = 0; idx < 3; idx++)
        {
            if (!key_type[idx] || !hash_valid[idx])
            {
                continue;
            }
            /*OAMHASHTYPE_ETH = 0x1*/
            value = key_type[idx] - 0x1 ;
            sal_sprintf(str, "hash-%d", idx);
            DIAG_INFO_CHAR(pos, str, lookup_result[value])
            if (confict[idx])
            {
                DIAG_INFO_CHAR(pos, "lookup-result", DIAG_LOOKUP_CONFLICT)
                DIAG_INFO_CHAR(pos, "key-name", key_name[value])
                DIAG_INFO_UINT32(pos, "key-index", key_index[idx])
            }
            else if (hash_resultValid[idx])
            {
                DIAG_INFO_CHAR(pos, "lookup-result", DIAG_LOOKUP_HIT)
                DIAG_INFO_CHAR(pos, "key-name", key_name[value])
                DIAG_INFO_UINT32(pos, "key-index", key_index[idx])
            }
            else
            {
                DIAG_INFO_CHAR(pos, "lookup-result", DIAG_LOOKUP_HIT_NONE)
            }
        }
    }

    if (hash_resultValid[0] || hash_resultValid[1] || hash_resultValid[2])
    {
        value = GetDbgIpeOamInfo(V, tempRxOamType_f, &ipe_oam_info);
        if (value)
        {
             /*RXOAMTYPE_TRILLBFD = 0xc*/
            char* oam_type[] =
            {
                "NONE", "ETHER OAM", "IP BFD", "RESERVED1", "RESERVED2",
                "RESERVED3", "MPLS OAM", "MPLS BFD", "ACH OAM", "NONE","TRILL BFD","TWAMP","FLEX PM TEST"

            };
            DIAG_INFO_CHAR(pos, "oam-type", STR_ARRAY(oam_type,value))
        }

        value = GetDbgIpeOamInfo(V, oamDestChipId_f, &ipe_oam_info);
        if (GetDbgIpeOamInfo(V, mepEn_f, &ipe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "MEP", "HIT")
            DIAG_INFO_UINT32(pos, "master-chip-id", value)
            DIAG_INFO_UINT32(pos, "mep-index", GetDbgIpeOamInfo(V, mepIndex_f, &ipe_oam_info))
        }
        if (GetDbgIpeOamInfo(V, mipEn_f, &ipe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "MIP", "HIT")
            DIAG_INFO_UINT32(pos, "master-chip-id", value)
        }

        if (GetDbgIpeOamInfo(V, mplsLmValid_f, &ipe_oam_info) || GetDbgIpeOamInfo(V, etherLmValid_f, &ipe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "action", "read-LM")
            DIAG_INFO_CHAR(pos, "table-name", "DsOamIpeLmStats")
            DIAG_INFO_UINT32(pos, "table-index", GetDbgIpeOamInfo(V, lmStatsIndex_f, &ipe_oam_info))

        }
        if (GetDbgIpeOamInfo(V, lmStatsEn0_f, &ipe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "action", "write-LM")
            DIAG_INFO_CHAR(pos, "table-name", "DsOamIpeLmStats")
            DIAG_INFO_UINT32(pos, "table-index", GetDbgIpeOamInfo(V, lmStatsPtr0_f, &ipe_oam_info))
        }
        if (GetDbgIpeOamInfo(V, lmStatsEn1_f, &ipe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "action", "write-LM")
            DIAG_INFO_CHAR(pos, "table-name", "DsOamIpeLmStats")
            DIAG_INFO_UINT32(pos, "table-index", GetDbgIpeOamInfo(V, lmStatsPtr1_f, &ipe_oam_info))
        }
        if (GetDbgIpeOamInfo(V, lmStatsEn2_f, &ipe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "action", "write-LM")
            DIAG_INFO_CHAR(pos, "table-name", "DsOamIpeLmStats")
            DIAG_INFO_UINT32(pos, "table-index", GetDbgIpeOamInfo(V, lmStatsPtr2_f, &ipe_oam_info))
        }
    }

    /* Exception Process */
    _sys_tmm_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                           GetDbgIpeOamInfo(V, exceptionEn_f, &ipe_oam_info),
                                           GetDbgIpeOamInfo(V, exceptionIndex_f, &ipe_oam_info),
                                           GetDbgIpeOamInfo(V, exceptionSubIndex_f, &ipe_oam_info));

    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_oam_rx_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_OAM;
    char* oam_pdu_type[] = {"OAM-TYPE-NONE", "ETHER-CCM", "ETHER-APS", "ETHER-1DM", "ETHER-DMM",
                          "ETHER-DMR", "ETHER-RAPS", "ETHER-LBM", "ETHER-LBR", "ETHER-LMR",
                          "ETHER-LMM", "MPLSTP-LBM", "ETHER-TST", "ETHER-LTR", "ETHER-LTM",
                          "ETHER-OTHER", "MPLSTP-DM", "MPLSTP-DLM", "MPLSTP-DLMDM", "MPLSTP-CV",
                          "MPLSTP-CSF", "ETHER-CSF", "ETHER-MCC", "MPLS-OTHER", "MPLSTP-MCC",
                          "MPLSTP-FM", "ETHER-SLM", "ETHER-SLR", "MPLS-OAM", "BFD-OAM",
                          "ETHER-SCC", "MPLSTP-SCC", "FLEX-TEST", "TWAMP", "ETHER-1SL",
                          "ETHER-LLM", "ETHER-LLR", "ETHER-SCM", "ETHER-SCR","ETHER_GNM","ETHER_BNM","ETHER_EDM"};

    DbgOamHdrAdj_m  oam_hdr_adj;
    DbgOamParser_m   oam_parser;
    DbgOamRxProc_m  oam_rx_proc;
    DbgOamDefectProc_m  oam_defect_proc;
    DbgOamHdrEdit_m     oam_hdr_edit;
    DbgOamApsSwitch_m oam_aps_switch;
    DbgOamApsProcess_m oam_aps_proc;
    DbgOamRmepHashInfo_m oam_rmep_hash_info;

    sal_memset(&oam_hdr_adj, 0, sizeof(oam_hdr_adj));
    cmd = DRV_IOR(DbgOamHdrAdj_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &oam_hdr_adj));

    sal_memset(&oam_parser, 0, sizeof(oam_parser));
    cmd = DRV_IOR(DbgOamParser_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &oam_parser));

    sal_memset(&oam_rx_proc, 0, sizeof(oam_rx_proc));
    cmd = DRV_IOR(DbgOamRxProc_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &oam_rx_proc));

    sal_memset(&oam_defect_proc, 0, sizeof(oam_defect_proc));
    cmd = DRV_IOR(DbgOamDefectProc_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &oam_defect_proc));

    sal_memset(&oam_hdr_edit, 0, sizeof(oam_hdr_edit));
    cmd = DRV_IOR(DbgOamHdrEdit_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &oam_hdr_edit));

    sal_memset(&oam_aps_switch, 0, sizeof(oam_aps_switch));
    cmd = DRV_IOR(DbgOamApsSwitch_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &oam_aps_switch));

    sal_memset(&oam_aps_proc, 0, sizeof(oam_aps_proc));
    cmd = DRV_IOR(DbgOamApsProcess_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &oam_aps_proc));

    sal_memset(&oam_rmep_hash_info, 0, sizeof(oam_rmep_hash_info));
    cmd = DRV_IOR(DbgOamRmepHashInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &oam_rmep_hash_info));

    if (!(GetDbgOamRmepHashInfo(V, valid_f, &oam_rmep_hash_info)
           ||GetDbgOamApsProcess(V, valid_f, &oam_aps_proc)
           ||GetDbgOamApsSwitch(V, valid_f, &oam_aps_switch)
           || GetDbgOamHdrEdit(V, valid_f, &oam_hdr_edit)
           || GetDbgOamDefectProc(V, valid_f, &oam_defect_proc)
           || GetDbgOamRxProc(V, valid_f, &oam_rx_proc)
           || GetDbgOamParser(V, valid_f, &oam_parser)
           || GetDbgOamHdrAdj(V, valid_f, &oam_hdr_adj)))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_OAM;
    DIAG_INFO_NONE(pos, "OAM RX Process")

    if (GetDbgOamHdrEdit(V, bypassAll_f, &oam_hdr_edit)
        || GetDbgOamRxProc(V, bypassAll_f, &oam_rx_proc))
    {
        DIAG_INFO_CHAR(pos, "oam-edit", "bypass-all")
    }
    if (GetDbgOamHdrEdit(V, discard_f, &oam_hdr_edit))
    {
        p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        DIAG_INFO_CHAR(pos, "discard", "TURE")
    }

    if (GetDbgOamHdrEdit(V, exception_f, &oam_hdr_edit))
    {
        p_rslt->dest_type = CTC_DIAG_DEST_CPU;
        DIAG_INFO_UINT32(pos, "exception-id", GetDbgOamHdrEdit(V, exception_f, &oam_hdr_edit))
    }

    /*oam parser*/
    if (GetDbgOamParser(V, oamPduInvalid_f, &oam_parser) || GetDbgOamParser(V, bfdOamPduInvalid_f, &oam_parser))
    {
        DIAG_INFO_CHAR(pos, "oam-pdu-type", STR_ARRAY(oam_pdu_type,GetDbgOamParser(V, oamType_f, &oam_parser)))

        if (GetDbgOamParser(V, bfdOamPduInvalid_f, &oam_parser))
        {
            DIAG_INFO_UINT32(pos, "dbit", GetDbgOamParser(V, u_bfd_dbit_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "my-disc", GetDbgOamParser(V, u_bfd_myDisc_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "your-disc", GetDbgOamParser(V, u_bfd_yourDisc_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "desired-min-tx-interval", GetDbgOamParser(V, u_bfd_desiredMinTxInterval_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "required-min-rx-interval", GetDbgOamParser(V, u_bfd_requiredMinRxInterval_f, &oam_parser))

            /*mpls-tp*/
            DIAG_INFO_UINT32(pos, "mpls-tp-dflags", GetDbgOamParser(V, u_tp_dflags_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "mpls-tp-csflags", GetDbgOamParser(V, u_tp_csfFlags_f, &oam_parser))

            /*twamp*/
            DIAG_INFO_UINT32(pos, "seqnum", GetDbgOamParser(V, u_twamp_seqNum_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "sender-seqnum", GetDbgOamParser(V, u_twamp_senderSeqNum_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "err-est-sbit", GetDbgOamParser(V, u_twamp_errEstSbit_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "err-est-zbit", GetDbgOamParser(V, u_twamp_errEstZbit_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "err-est-scale", GetDbgOamParser(V, u_twamp_errEstScale_f, &oam_parser))
            DIAG_INFO_UINT32(pos, "err-est-mult", GetDbgOamParser(V, u_twamp_errEstMult_f, &oam_parser))
        }
        else if(GetDbgOamParser(V, oamPduInvalid_f, &oam_parser))
        {
            DIAG_INFO_UINT32(pos, "md-level", GetDbgOamParser(V, u_ethoam_mdlevel_f, &oam_parser))
        }
    }

    /*oam rx proc*/
    if (GetDbgOamRxProc(V, valid_f, &oam_rx_proc))
    {
        DIAG_INFO_UINT32(pos, "mep-index", GetDbgOamRxProc(V, mepIndex_f, &oam_rx_proc))
        DIAG_INFO_UINT32(pos, "ma-index", GetDbgOamRxProc(V, maIndex_f, &oam_rx_proc))
        DIAG_INFO_UINT32(pos, "rmep-index", GetDbgOamRxProc(V, rmepIndex_f, &oam_rx_proc))

        DIAG_INFO_UINT32(pos, "Rx-exception", GetDbgOamRxProc(V, exception_f, &oam_rx_proc))
        if (GetDbgOamRxProc(V, linkOam_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "LinkOAM", "YES")
        }
        if (GetDbgOamRxProc(V, lowCcm_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "LowCCM", "YES")
        }
        if (GetDbgOamRxProc(V, lowSlowOam_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "LowSlowCCM", "YES")
        }
        if (GetDbgOamRxProc(V, mipEn_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "MipEn", "YES")
        }

        if (GetDbgOamRxProc(V, equalBfd_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "BFD-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalCcm_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "CCM-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalDm_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "DM-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalEthTst_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "Tst-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalFlexTest_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "FlexTest-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalLb_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "LB-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalLm_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "LM-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalSm_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "SM-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalTwamp_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "TWAMP-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, equalSBfdReflector_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "SBFD-Reflector-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, sBfdInitiatorRxEn_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "SBFD-Initiator-Proc", "YES")
        }
        if (GetDbgOamRxProc(V, isMdLvlMatch_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "Md-Lvl-Match", "YES")
        }
        if (GetDbgOamRxProc(V, isUp_f, &oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "is-up", "YES")
        }
    }

    if ( GetDbgOamDefectProc(V, valid_f, &oam_defect_proc)
        && (GetDbgOamDefectProc(V, defectSubType_f, &oam_defect_proc)
            || GetDbgOamDefectProc(V, defectType_f, &oam_defect_proc)))
    {
        DIAG_INFO_UINT32(pos, "oam-defect-type", GetDbgOamDefectProc(V, defectType_f, &oam_defect_proc))
        DIAG_INFO_UINT32(pos, "oam-defect-sub-type", GetDbgOamDefectProc(V, defectSubType_f, &oam_defect_proc))
    }

   /*rmep hash info*/
    if (GetDbgOamRmepHashInfo(V, valid_f, &oam_rmep_hash_info) && GetDbgOamRmepHashInfo(V, resultValid_f, &oam_rmep_hash_info))
    {
        DIAG_INFO_CHAR(pos, "oam-rmep-lookup-result", DIAG_LOOKUP_HIT)
        DIAG_INFO_CHAR(pos, "key-name", (GetDbgOamRmepHashInfo(V, hashConflict_f, &oam_rmep_hash_info) ? "DsEthOamRmepHashCam" : "DsEthOamRmepRmepHashKey"))
        DIAG_INFO_UINT32(pos, "key-index", GetDbgOamRmepHashInfo(V, keyIndex_f, &oam_rmep_hash_info))
        DIAG_INFO_UINT32(pos, "mep-index", GetDbgOamRmepHashInfo(V, mepIndex_f, &oam_rmep_hash_info))
        DIAG_INFO_UINT32(pos, "rmep-Id", GetDbgOamRmepHashInfo(V, rmepId_f, &oam_rmep_hash_info))
    }

    /*oam head edit*/
    if (GetDbgOamHdrEdit(V, bypassAll_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "bypass-all")
    }
    if (GetDbgOamHdrEdit(V, isDefectFree_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "no-defect")
    }
    if (GetDbgOamHdrEdit(V, discard_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "discard")
    }
    if (GetDbgOamHdrEdit(V, equalDm_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "DM-Proc")
    }
    if (GetDbgOamHdrEdit(V, equalLb_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "LB-Proc")
    }
    if (GetDbgOamHdrEdit(V, equalLm_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "LM-Proc")
    }
    if (GetDbgOamHdrEdit(V, equalSm_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "SM-Proc")
    }
    if (GetDbgOamHdrEdit(V, equalTwamp_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "TWAMP-Proc")
    }
    if (GetDbgOamHdrEdit(V, twampAck_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "TWAMP-ACK-Proc")
    }
    if (GetDbgOamHdrEdit(V, equalSBfdReflector_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "SBFD-Proc")
    }
#if 0
    if (GetDbgOamHdrEdit(V, oamHdrEditEqualPeriodTest_f, &oam_hdr_edit))
    {
        DIAG_INFO_CHAR(pos, "oam-header-edit-process", "NPM-LITE")
    }
#endif
    if (GetDbgOamApsSwitch(V, valid_f, &oam_aps_switch))
    {
        DIAG_INFO_UINT32(pos, "aps-group", GetDbgOamApsSwitch(V, apsGroupId_f, &oam_aps_switch))
        if (GetDbgOamApsSwitch(V, signalOk_f, &oam_aps_switch))
        {
            DIAG_INFO_CHAR(pos, "aps-switch-signal", "OK")
        }
        if (GetDbgOamApsSwitch(V, signalFail_f, &oam_aps_switch))
        {
            DIAG_INFO_CHAR(pos, "aps-switch-signal", "FAIL")
        }
        if (GetDbgOamApsSwitch(V, protectionFail_f, &oam_aps_switch))
        {
            DIAG_INFO_CHAR(pos, "aps-switch-protection", "FAIL")
        }
        if (GetDbgOamApsSwitch(V, workingFail_f, &oam_aps_switch))
        {
            DIAG_INFO_CHAR(pos, "aps-switch-working", "FAIL")
        }
    }
    else if (!GetDbgOamApsSwitch(V, valid_f, &oam_aps_switch)
            && GetDbgOamApsProcess(V, valid_f, &oam_aps_proc))
    {
        if (GetDbgOamApsProcess(V, signalOk_f, &oam_aps_proc))
        {
            DIAG_INFO_CHAR(pos, "aps-process-signal", "OK")
        }
        if (GetDbgOamApsProcess(V, signalFail_f, &oam_aps_proc))
        {
            DIAG_INFO_CHAR(pos, "aps-process-signal", "FAIL")
        }
        if (GetDbgOamApsProcess(V, updateApsEn_f, &oam_aps_proc))
        {
            DIAG_INFO_CHAR(pos, "aps-process-update", "ENABLE")
        }
    }

    p_rslt->dest_type = CTC_DIAG_DEST_OAM;
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_oam_tx_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_OAM;
    char* rx_oam_type[] = {"NONE", "ETHEROAM", "IPBFD", "PBTOAM", "PBBBSI",
                          "PBBBV", "MPLSOAM", "MPLSBFD", "ACHOAM", "TRILLBFD",
                          "TWAMP", "FLEX_PM_TEST"};
    char* packet_type[] = {"ETHERNET", "IPV4", "MPLS", "IPV6", "MPLSUP",
                          "IP", "FLEXIBLE", "RESERVED"};
    DbgOamTxProc_m   oam_tx_proc;

    sal_memset(&oam_tx_proc, 0, sizeof(oam_tx_proc));
    cmd = DRV_IOR(DbgOamTxProc_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &oam_tx_proc));

    if (!GetDbgOamTxProc(V, valid_f, &oam_tx_proc))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_OAM;
    DIAG_INFO_NONE(pos, "OAM TX Process")

    DIAG_INFO_CHAR(pos, "tx-oam-type", STR_ARRAY(rx_oam_type,GetDbgOamTxProc(V, rxOamType_f, &oam_tx_proc)))
    DIAG_INFO_CHAR(pos, "packet-type", STR_ARRAY(packet_type,GetDbgOamTxProc(V, packetType_f, &oam_tx_proc)))
    DIAG_INFO_UINT32(pos, "nexthop-ptr", GetDbgOamTxProc(V, nextHopPtr_f, &oam_tx_proc))
    DIAG_INFO_U32_HEX(pos, "dest-map", GetDbgOamTxProc(V, destMap_f, &oam_tx_proc))

    if (GetDbgOamTxProc(V, isEth_f, &oam_tx_proc))
    {
        DIAG_INFO_CHAR(pos, "is-Eth", "YES")
    }
    if (GetDbgOamTxProc(V, isTxCv_f, &oam_tx_proc))
    {
        DIAG_INFO_CHAR(pos, "is-TxCv", "YES")
    }
    if (GetDbgOamTxProc(V, isTxCsf_f, &oam_tx_proc))
    {
        DIAG_INFO_CHAR(pos, "is-TxCsf", "YES")
    }
    if (GetDbgOamTxProc(V, isUp_f, &oam_tx_proc))
    {
        DIAG_INFO_CHAR(pos, "is-UpMep", "YES")
    }
#if 0

    if (GetDbgOamTxProc(V, oamTxProcIsTxPeriodTest_f, &oam_tx_proc))
    {
        DIAG_INFO_CHAR(pos, "is-Npm-Lite", "YES")
    }
#endif
    p_rslt->dest_type = CTC_DIAG_DEST_OAM;
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_sc_oam_tx_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_SC_OAM;
    DbgFlexEOamTxProc_m   sc_oam_tx_proc;

    sal_memset(&sc_oam_tx_proc, 0, sizeof(sc_oam_tx_proc));
    cmd = DRV_IOR(DbgFlexEOamTxProc_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &sc_oam_tx_proc));

    if (!GetDbgFlexEOamTxProc(V, valid_f, &sc_oam_tx_proc))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_SC_OAM;
    DIAG_INFO_NONE(pos, "SC OAM TX Process")

    DIAG_INFO_UINT32(pos, "hw-client-id", GetDbgFlexEOamTxProc(V, clientId_f, &sc_oam_tx_proc))

    if (GetDbgFlexEOamTxProc(V, isApsTx_f, &sc_oam_tx_proc))
    {
        DIAG_INFO_CHAR(pos, "is-Aps", "YES")
    }
    if (GetDbgFlexEOamTxProc(V, isBasTx_f, &sc_oam_tx_proc))
    {
        DIAG_INFO_CHAR(pos, "is-Bas", "YES")
    }
    if (GetDbgFlexEOamTxProc(V, isCsTx_f, &sc_oam_tx_proc))
    {
        DIAG_INFO_CHAR(pos, "is-Cs", "YES")
    }
    if (GetDbgFlexEOamTxProc(V, isCvTx_f, &sc_oam_tx_proc))
    {
        DIAG_INFO_CHAR(pos, "is-Cv", "YES")
    }
    if (GetDbgFlexEOamTxProc(V, isDmTx_f, &sc_oam_tx_proc))
    {
        DIAG_INFO_CHAR(pos, "is-Dm", "YES")
    }
    p_rslt->dest_type = CTC_DIAG_DEST_SC_OAM;
    return CTC_E_NONE;
}


STATIC int32
_sys_tmm_diag_pkt_trace_get_sc_oam_rx_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_SC_OAM;
    uint8 oam_type = 0;
    uint32 txrxTs = 0;
    uint64 val_64 = 0;
    uint32 array_value[2] = {0};
    DbgFlexEOamParser_m  sc_oam_parser;
    DbgFlexEOamPktEdit_m   sc_oam_pkt_edit;
    DbgFlexEOamRxProc_m  sc_oam_rx_proc;
    char* rx_sc_oam_type[] = {"NONE", "BAS", "APS", "CV", "1DM",
                          "DMM", "DMR", "CS"};

    sal_memset(&sc_oam_parser, 0, sizeof(sc_oam_parser));
    cmd = DRV_IOR(DbgFlexEOamParser_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &sc_oam_parser));

    sal_memset(&sc_oam_pkt_edit, 0, sizeof(sc_oam_pkt_edit));
    cmd = DRV_IOR(DbgFlexEOamPktEdit_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &sc_oam_pkt_edit));

    sal_memset(&sc_oam_rx_proc, 0, sizeof(sc_oam_rx_proc));
    cmd = DRV_IOR(DbgFlexEOamRxProc_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &sc_oam_rx_proc));

    if (!(GetDbgFlexEOamParser(V, valid_f, &sc_oam_parser)
           || GetDbgFlexEOamPktEdit(V, valid_f, &sc_oam_pkt_edit)
           || GetDbgFlexEOamRxProc(V, valid_f, &sc_oam_rx_proc)))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_SC_OAM;
    DIAG_INFO_NONE(pos, "SC OAM RX Process")
    /*sc oam parser*/
    if (GetDbgFlexEOamParser(V, valid_f, &sc_oam_parser))
    {
        oam_type =  GetDbgFlexEOamParser(V, oamType_f, &sc_oam_parser);
        DIAG_INFO_CHAR(pos, "sc-oam-type", ((0xF == oam_type) ? "OTHER" : rx_sc_oam_type[oam_type]))
        DIAG_INFO_CHAR(pos, "sc-oam-pdu-invalid", (GetDbgFlexEOamParser(V, flexOamPduInvalid_f, &sc_oam_parser) ? DIAG_YES : DIAG_NO))
        DIAG_INFO_UINT32(pos, "sc-oam-ccode", GetDbgFlexEOamParser(V, cCode_f, &sc_oam_parser))
        DIAG_INFO_UINT32(pos, "sc-oam-crc", GetDbgFlexEOamParser(V, crc_f, &sc_oam_parser))
        DIAG_INFO_UINT32(pos, "sc-oam-seq", GetDbgFlexEOamParser(V, seq_f, &sc_oam_parser))
        DIAG_INFO_UINT32(pos, "sc-oam-spnCodeType", GetDbgFlexEOamParser(V, spnCodeType_f, &sc_oam_parser))

        if (0x1 == oam_type)
        {
            /*1bit yes or no ?*/
            DIAG_INFO_UINT32(pos, "bas-cslf", GetDbgFlexEOamParser(V, u_gBas_csLf_f, &sc_oam_parser))
            DIAG_INFO_UINT32(pos, "bas-cslpi", GetDbgFlexEOamParser(V, u_gBas_csLpi_f, &sc_oam_parser))
            DIAG_INFO_UINT32(pos, "bas-csrf", GetDbgFlexEOamParser(V, u_gBas_csRf_f, &sc_oam_parser))
            DIAG_INFO_UINT32(pos, "bas-rdi", GetDbgFlexEOamParser(V, u_gBas_rdi_f, &sc_oam_parser))

            DIAG_INFO_UINT32(pos, "bas-rei", GetDbgFlexEOamParser(V, u_gBas_rei_f, &sc_oam_parser))
            DIAG_INFO_UINT32(pos, "bas-bip", GetDbgFlexEOamParser(V, u_gBas_bip_f, &sc_oam_parser))
            DIAG_INFO_UINT32(pos, "bas-period", GetDbgFlexEOamParser(V, u_gBas_period_f, &sc_oam_parser))
        }
        else if (0x3 == oam_type)
        {
            DIAG_INFO_UINT32(pos, "cv-sapiOrDapi0", GetDbgFlexEOamParser(V, u_gCv_sapiOrDapi0_f, &sc_oam_parser))
            DIAG_INFO_UINT32(pos, "cv-sapiOrDapi1", GetDbgFlexEOamParser(V, u_gCv_sapiOrDapi1_f, &sc_oam_parser))
            DIAG_INFO_UINT32(pos, "cv-sapiOrDapi2", GetDbgFlexEOamParser(V, u_gCv_sapiOrDapi2_f, &sc_oam_parser))
            DIAG_INFO_UINT32(pos, "cv-sapiOrDapi3", GetDbgFlexEOamParser(V, u_gCv_sapiOrDapi3_f, &sc_oam_parser))
        }
        else if (0x4 == oam_type || 0x5 == oam_type)
        {
             txrxTs = ((GetDbgFlexEOamParser(V, u_gDm_txrxTs3_f, &sc_oam_parser)&0x000000FF) << 24)|
                     ((GetDbgFlexEOamParser(V, u_gDm_txrxTs2_f, &sc_oam_parser)&0x000000FF) <<16 )|
                     ((GetDbgFlexEOamParser(V, u_gDm_txrxTs1_f, &sc_oam_parser)&0x000000FF) << 8)|
                     (GetDbgFlexEOamParser(V, u_gDm_txrxTs0_f, &sc_oam_parser)&0x000000FF);

            DIAG_INFO_UINT32(pos, "TxTimerStampf", txrxTs)
        }
        else if (0x7 == oam_type)
        {
            DIAG_INFO_UINT32(pos, "cs-type", GetDbgFlexEOamParser(V, u_gCs_csType_f, &sc_oam_parser))
        }
        else
        {
            GetDbgFlexEOamParser(A, u_gOther_oamBlockData_f, &sc_oam_parser, array_value);
            val_64 = array_value[1];
            val_64 = val_64 << 32 | array_value[0];
            DIAG_INFO_U64_HEX(pos, "oam-block-data", val_64)
        }
    }

    /*sc oam rx proc*/
    if (GetDbgFlexEOamRxProc(V, valid_f, &sc_oam_rx_proc))
    {
        if (GetDbgFlexEOamRxProc(V, byPassAll_f, &sc_oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "oam-edit", "bypass-all")
        }
        if (GetDbgFlexEOamRxProc(V, dmmReply_f, &sc_oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "DmmReply", "YES")
        }
        if (GetDbgFlexEOamRxProc(V, _1DmRxComplete_f, &sc_oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "1DmRxComplete", "YES")
        }
        if (GetDbgFlexEOamRxProc(V, dmmRxComplete_f, &sc_oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "DmmRxComplete", "YES")
        }
        if (GetDbgFlexEOamRxProc(V, dmrRxComplete_f, &sc_oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "DmrRxComplete", "YES")
        }
        if (GetDbgFlexEOamRxProc(V, cvRxComplete_f, &sc_oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "cvRxComplete", "YES")
        }
        if (GetDbgFlexEOamRxProc(V, isAps_f, &sc_oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "sc-oam-aps", "YES")
        }
        if (GetDbgFlexEOamRxProc(V, isBas_f, &sc_oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "sc-oam-bas", "YES")
        }
        if (GetDbgFlexEOamRxProc(V, isCs_f, &sc_oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "sc-oam-cs", "YES")
        }
        if (GetDbgFlexEOamRxProc(V, isCv_f, &sc_oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "sc-oam-cv", "YES")
        }
        if (GetDbgFlexEOamRxProc(V, isDm_f, &sc_oam_rx_proc))
        {
            DIAG_INFO_CHAR(pos, "sc-oam-dm", "YES")
        }
        DIAG_INFO_UINT32(pos, "dma-dm-type", GetDbgFlexEOamRxProc(V, dmaDmType_f, &sc_oam_rx_proc))
        val_64=0;
        sal_memset(array_value,0,sizeof(array_value));
        GetDbgFlexEOamRxProc(A, rxTimeStamp_f, &sc_oam_rx_proc, array_value);
        val_64 = array_value[1];
        val_64 = val_64 << 32 | array_value[0];
        DIAG_INFO_U64_HEX(pos, "rx-time-stamp", val_64)

        val_64=0;
        sal_memset(array_value,0,sizeof(array_value));
        GetDbgFlexEOamRxProc(A, defectTypeVector_f, &sc_oam_rx_proc, array_value);
        val_64 = array_value[1];
        val_64 = val_64 << 32 | array_value[0];
        DIAG_INFO_U64_HEX(pos, "defect-type-vector", val_64)
    }
    /*sc oam pkt edit*/
    if (GetDbgFlexEOamPktEdit(V, valid_f, &sc_oam_pkt_edit))
    {
        if (GetDbgFlexEOamPktEdit(V, dmmReply_f, &sc_oam_pkt_edit))
        {
            DIAG_INFO_CHAR(pos, "dmm-reply", "YES")
        }
        DIAG_INFO_UINT32(pos, "hw-client-id", GetDbgFlexEOamPktEdit(V, clientId_f, &sc_oam_pkt_edit))
    }
    p_rslt->dest_type = CTC_DIAG_DEST_SC_OAM;
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_ipe_cid_pair_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 value = 0;
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    char*  str_hash_key_name[] = {"DsCategoryIdPairHashRightKey", "DsCategoryIdPairHashLeftKey"};
    char*  str_hash_ad_name[] = {"DsCategoryIdPairHashRightAd", "DsCategoryIdPairHashLeftAd"};
    DbgIpeAclProcInfo0_m   acl_info;
    DsCategoryIdPair_m     ds_cid_pair;

    sal_memset(&ds_cid_pair, 0, sizeof(DsCategoryIdPair_m));
    sal_memset(&acl_info, 0, sizeof(DbgIpeAclProcInfo0_m));

    cmd = DRV_IOR(IpeFwdCategoryCtl_t, IpeFwdCategoryCtl_categoryIdPairLookupEn_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
    if (!value)
    {
        return CTC_E_NONE;
    }

    cmd = DRV_IOR(DbgIpeAclProcInfo0_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &acl_info));

    if(GetDbgIpeAclProcInfo0(V, gCidLkp_srcCategoryIdClassfied_f , &acl_info))
    {
        DIAG_INFO_UINT32(pos, "source-category-id", GetDbgIpeAclProcInfo0(V, gCidLkp_srcCategoryId_f, &acl_info))
    }

    if(GetDbgIpeAclProcInfo0(V, gCidLkp_destCategoryIdClassfied_f, &acl_info))
    {
        DIAG_INFO_UINT32(pos, "dest-category-id", GetDbgIpeAclProcInfo0(V, gCidLkp_destCategoryId_f, &acl_info))
    }

    if (GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairHashHit_f, &acl_info))
    {
        value = GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairHashIsLeft_f, &acl_info);
        DIAG_INFO_CHAR(pos, "cid-lookup-result", "HIT-HASH")

        DIAG_INFO_CHAR(pos, "key-name", STR_ARRAY(str_hash_key_name,value))
        DIAG_INFO_UINT32(pos, "key-index", GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairHashKeyIndex_f, &acl_info))
        DIAG_INFO_CHAR(pos, "ad-name", STR_ARRAY(str_hash_ad_name,value))
        DIAG_INFO_UINT32(pos, "ad-index", GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairHashAdIndex_f, &acl_info))
        DIAG_INFO_UINT32(pos, "array-offset", GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairHashEntryOffset_f, &acl_info))
        if(value)
        {
            cmd = DRV_IOR(DsCategoryIdPairHashLeftAd_t, DRV_ENTRY_FLAG);
        }
        else
        {
            cmd = DRV_IOR(DsCategoryIdPairHashRightAd_t, DRV_ENTRY_FLAG);
        }
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairHashAdIndex_f, &acl_info), cmd, &ds_cid_pair));
    }
    else if (GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairTcamResultValid_f , &acl_info))
    {
        value = GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairTcamHitIndex_f, &acl_info);
        DIAG_INFO_CHAR(pos, "cid-lookup-result", "HIT-TCAM")
        DIAG_INFO_CHAR(pos, "key-name", "DsCategoryIdPairTcamKey")
        DIAG_INFO_UINT32(pos, "key-index", value)
        DIAG_INFO_CHAR(pos, "ad-name", "DsCategoryIdPairTcamAd")
        DIAG_INFO_UINT32(pos, "ad-index", value)
        cmd = DRV_IOR(DsCategoryIdPairTcamAd_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, value, cmd, &ds_cid_pair));
    }
    else
    {
        DIAG_INFO_CHAR(pos, "cid-lookup-result", DIAG_LOOKUP_HIT_NONE)
    }

    if(GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairHashHit_f, &acl_info)
       || GetDbgIpeAclProcInfo0(V, gCidLkp_cidPairTcamResultValid_f , &acl_info))
    {
        if (GetDsCategoryIdPair(V, operationMode_f, &ds_cid_pair))
        {
            if (GetDsCategoryIdPair(V, u1_g2_permit_f, &ds_cid_pair))
            {
                DIAG_INFO_CHAR(pos, "cid-pair-action", "PERMIT")
            }
            else if (GetDsCategoryIdPair(V, u1_g2_deny_f, &ds_cid_pair))
            {
                DIAG_INFO_CHAR(pos, "cid-pair-action", "DENY")
            }
        }
        else
        {
            char str[64] = {0};
            sal_sprintf(str, "OverWrite-ACL-Level-%d", GetDsCategoryIdPair(V, aclLookupLevel_f, &ds_cid_pair));
            DIAG_INFO_CHAR(pos, "cid-pair-action", str)
            DIAG_INFO_UINT32(pos, "acl-lookup-type", GetDsCategoryIdPair(V, u1_g1_lookupType_f, &ds_cid_pair))

            if(!GetDsCategoryIdPair(V, u1_g1_keepAclLabel_f, &ds_cid_pair))
            {
                DIAG_INFO_UINT32(pos, "acl-label", GetDsCategoryIdPair(V, u1_g1_aclLabel_f, &ds_cid_pair))
            }
            if(!GetDsCategoryIdPair(V, u1_g1_keepAclUsePIVlan_f, &ds_cid_pair))
            {
                DIAG_INFO_UINT32(pos, "use-mapped-vlan", GetDsCategoryIdPair(V, u1_g1_aclUsePIVlan_f, &ds_cid_pair))
            }
            if (!GetDsCategoryIdPair(V, u1_g1_keepAclUseGlobalPortType_f, &ds_cid_pair))
            {
                DIAG_INFO_UINT32(pos, "use-mapped-gport", GetDsCategoryIdPair(V, u1_g1_aclUseGlobalPortType_f, &ds_cid_pair))
            }
        }
    }

    return CTC_E_NONE;
}

#if 0
enum sys_acl_key_ltid_type_e
{
    SYS_ACL_KEY_LTID_MAC          = 1,                /**< [GB.GG.D2.TM] ACL MAC key type */
    SYS_ACL_KEY_LTID_IPV4         = 2,               /**< [GB.GG.D2.TM] ACL IPv4 key type */
    SYS_ACL_KEY_LTID_MPLS         = 3,              /**< [GB.GG] ACL MPLS key type, In DT2, replaced by SYS_ACL_KEY_LTID_MAC_IPV4*/
    SYS_ACL_KEY_LTID_IPV6         = 4,               /**< [GB.GG.D2.TM] Mode 0: ACL Mac+IPv6 key type, Mode 1: ACL Ipv6 key type */
    SYS_ACL_KEY_LTID_IPV4_EXT     = 5,           /**< [D2.TM] ACL IPv4 extend key type */
    SYS_ACL_KEY_LTID_MAC_IPV4     = 6,           /**< [D2.TM] ACL Mac+IPv4 key type */
    SYS_ACL_KEY_LTID_MAC_IPV4_EXT = 7,       /**< [D2.TM] ACL Mac+IPv4 extend key type */
    SYS_ACL_KEY_LTID_IPV6_EXT     = 8,           /**< [D2.TM] ACL IPv6 extend key type */
    SYS_ACL_KEY_LTID_MAC_IPV6     = 9,           /**< [D2.TM] ACL Mac+IPv6 extend key type */
    SYS_ACL_KEY_LTID_CID          = 10,                /**< [D2.TM] ACL Category Id key type */
    SYS_ACL_KEY_LTID_INTERFACE    = 11,          /**< [D2.TM] ACL Interface key type */
    SYS_ACL_KEY_LTID_FWD          = 12,                /**< [D2.TM] ACL Forward key type */
    SYS_ACL_KEY_LTID_FWD_EXT      = 13,            /**< [D2.TM] ACL Forward key type */
    SYS_ACL_KEY_LTID_COPP         = 14,               /**< [D2.TM] ACL Copp key type */
    SYS_ACL_KEY_LTID_COPP_EXT     = 15,           /**< [D2.TM] ACL Copp extend key type */
    SYS_ACL_KEY_LTID_UDF          = 16,                /**< [TM] ACL UDF key type */
    SYS_ACL_KEY_LTID_SH           = 17,                /**< [TM] ACL UDF key type */
    SYS_ACL_KEY_LTID_MAX

};
#endif

STATIC int32
_sys_tmm_diag_pkt_trace_get_ipe_acl_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    uint8  loop = 0;
    char ltid_lkup_rslt[12] = "";
    char acl_lkup_key[12] = "";
    char* const lookup_result[] = {
                "TCAM0-lookup-result", "TCAM1-lookup-result", "TCAM2-lookup-result", "TCAM3-lookup-result",
                "TCAM4-lookup-result", "TCAM5-lookup-result", "TCAM6-lookup-result", "TCAM7-lookup-result",
                "TCAM8-lookup-result", "TCAM9-lookup-result", "TCAM10-lookup-result", "TCAM11-lookup-result",
                "TCAM12-lookup-result", "TCAM13-lookup-result", "TCAM14-lookup-result", "TCAM15-lookup-result"
            };
    char* const key_type[] = {
            "MAC_KEY",      "IPV4_KEY",     /*"MPLS_KEY",*/         "IPV6_KEY",
            "IPV4_EXT_KEY", "MAC_IPV4_KEY", "MAC_IPV4_EXT_KEY", "IPV6_EXT_KEY",
            "MAC_IPV6_KEY", "CID_KEY",      "INTERFACE_KEY",    "FWD_KEY",
            "FWD_EXT_KEY",  "COPP_KEY",     "COPP_EXT_KEY",     "UDF_KEY",
            "STK_HDR_KEY"};
    char* const key_LenType[] = {"160(bit)","320(bit)", "480(bit)", "None"};
    uint8  step1 = DbgProgramLtidTcamEngineIpeAclInfo_gAclLookup_1_lookupEn_f - DbgProgramLtidTcamEngineIpeAclInfo_gAclLookup_0_lookupEn_f;
    uint8  key_len_type = 0;
    uint8  lkup_level = 0;
    uint8  ltid = 0;
    uint32 hw_index = 0, hit_index = 0;
    uint32 data_buf[5] = {0};
    DbgIpeAclProcInfo0_m acl_proc0_info;
    DbgProgramLtidTcamEngineIpeAclKeyInfo_m ltid_key;
    DbgProgramLtidTcamEngineIpeAclInfo_m ltid_info;
    DbgProgramAclTcamEngineIpeAclKeyInfo0_m acl_key;
    DbgProgramAclTcamEngineIpeAclInfo0_m acl_info;

    sal_memset(&acl_proc0_info, 0, sizeof(DbgIpeAclProcInfo0_m));
    cmd = DRV_IOR(DbgIpeAclProcInfo0_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &acl_proc0_info));

    cmd = DRV_IOR(DbgProgramLtidTcamEngineIpeAclInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ltid_info));
    cmd = DRV_IOR(DbgProgramLtidTcamEngineIpeAclKeyInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ltid_key));

    if (!GetDbgProgramLtidTcamEngineIpeAclInfo(V, valid_f, &ltid_info) && !GetDbgIpeAclProcInfo0(V, valid_f, &acl_proc0_info))
    {
        return CTC_E_NONE;
    }

    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "ACL/TCAM Processing")

    DIAG_INFO_UINT32(pos, "exception-id", GetDbgIpeAclProcInfo0(V, exceptionId_f, &acl_proc0_info))
    DIAG_INFO_CHAR(pos, "from-stk", GetDbgIpeAclProcInfo0(V, fromCflex_f, &acl_proc0_info)? DIAG_YES: DIAG_NO)
    DIAG_INFO_CHAR(pos, "mac-known", GetDbgIpeAclProcInfo0(V, macKnown_f, &acl_proc0_info)? DIAG_YES: DIAG_NO)
    DIAG_INFO_U32_HEX(pos, "log-vector", GetDbgIpeAclProcInfo0(V, tempLogVector_f, &acl_proc0_info))
    if (1 == GetDbgProgramLtidTcamEngineIpeAclKeyInfo(V, valid_f, &ltid_key))
    {
        DIAG_INFO_CHAR(pos, "acl-use-outer", GetDbgProgramLtidTcamEngineIpeAclKeyInfo(V, aclUseInnerPktInfo_f, &ltid_key)? DIAG_NO: DIAG_YES)
        GetDbgProgramLtidTcamEngineIpeAclKeyInfo(A, ltidKey_f, &ltid_key, data_buf);
        DIAG_INFO_UDF(pos, "ltid-key", data_buf)
    }

    for (loop=0; loop<DIAG_IGS_ACL_LKUP_NUM; loop++)
    {
        if (0 == GetDbgProgramLtidTcamEngineIpeAclInfo(V, gAclLookup_0_lookupEn_f + step1*loop, &ltid_info))
        {
            continue;
        }
   
        cmd = DRV_IOR(DbgProgramAclTcamEngineIpeAclInfo0_t + loop, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &acl_info));
        cmd = DRV_IOR(DbgProgramAclTcamEngineIpeAclKeyInfo0_t + loop, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &acl_key));
        sal_sprintf(ltid_lkup_rslt, "ltid-hit%-2d", loop);

        if (1 == GetDbgProgramLtidTcamEngineIpeAclInfo(V, gAclLookup_0_ltidHit_f + step1*loop, &ltid_info))
        {
            DIAG_INFO_CHAR(pos, ltid_lkup_rslt, DIAG_LOOKUP_HIT)
        }
        else
        {
            DIAG_INFO_CHAR(pos, ltid_lkup_rslt, DIAG_LOOKUP_DEFAULT)
        }
        DIAG_INFO_UINT32(pos, "ltid-ad-index", GetDbgProgramLtidTcamEngineIpeAclInfo(V, gAclLookup_0_dsLtidSelectAdAddr_f + step1*loop, &ltid_info))

        ltid = GetDbgProgramAclTcamEngineIpeAclInfo0(V, ltid_f, &acl_info);
        key_len_type = GetDbgProgramAclTcamEngineIpeAclInfo0(V, keyLenType_f, &acl_info);
        if ((1 == GetDbgProgramAclTcamEngineIpeAclInfo0(V, valid_f, &acl_info)) &&
            (1 == GetDbgProgramAclTcamEngineIpeAclInfo0(V, hit_f, &acl_info)) &&
            (key_len_type != 3))
        {
            hw_index = GetDbgProgramAclTcamEngineIpeAclInfo0(V, index_f, &acl_info);
            _sys_tmm_diag_map_tcam_key_index(lchip, hw_index, 1, loop, &hit_index);
            if (0 == key_len_type)
            {
                lkup_level = loop;
            }
            else
            {
                lkup_level = loop - 1;
            }
            DIAG_INFO_CHAR(pos, STR_ARRAY(lookup_result,lkup_level), DIAG_LOOKUP_HIT);
            DIAG_INFO_UINT32(pos, "key-index", hit_index)
            if ((ltid>=16) && (ltid<32))
            {
                DIAG_INFO_CHAR(pos, "key-type", STR_ARRAY(key_type,(ltid-16)))
            }
            else
            {
                DIAG_INFO_UINT32(pos, "key-ltid", ltid)
                DIAG_INFO_CHAR(pos, "key-length",STR_ARRAY(key_LenType,key_len_type))
            }
        }
        else if ((1 == GetDbgProgramAclTcamEngineIpeAclInfo0(V, valid_f, &acl_info)) && (0 == GetDbgProgramAclTcamEngineIpeAclInfo0(V, hit_f, &acl_info)))
        {
            if (3 != key_len_type)
            {
                DIAG_INFO_CHAR(pos, STR_ARRAY(lookup_result,loop), DIAG_LOOKUP_HIT_NONE)
                if ((ltid>=16) && (ltid<32))
                {
                    DIAG_INFO_CHAR(pos, "key-type",STR_ARRAY(key_type,(ltid-16)))
                }
                else
                {
                    DIAG_INFO_UINT32(pos, "key-ltid", ltid)
                    DIAG_INFO_CHAR(pos, "key-length",STR_ARRAY(key_LenType,key_len_type))
                }
            }
        }
        if (1 == GetDbgProgramAclTcamEngineIpeAclKeyInfo0(V, valid_f, &acl_key))
        {
            GetDbgProgramAclTcamEngineIpeAclKeyInfo0(A, key_f, &acl_key, data_buf);
            sal_sprintf(acl_lkup_key, "lkup-key%-2d", loop);
            DIAG_INFO_U32_LIST(pos, acl_lkup_key, data_buf, 5);
            DIAG_INFO_NONE(pos," ")
        }
    }
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipe_cid_pair_info(lchip, p_rslt));
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_ipfix_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt, uint8 dir)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    DbgIpfixAccInfo0_m  ipfixAccInfo;
    DbgIpfixAccInfo1_m  ipfixAccInfo1;

    if (dir == 0)
    {
        cmd = DRV_IOR(DbgIpfixAccInfo0_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ipfixAccInfo));
        if (!GetDbgIpfixAccInfo0(V, valid_f, &ipfixAccInfo))
        {
            return CTC_E_NONE;
        }
        DIAG_INFO_NONE(pos, "Ingress Ipfix Process")
        DIAG_INFO_CHAR(pos, "ipfix-enable", GetDbgIpfixAccInfo0(V, ipfixEn_f, &ipfixAccInfo) ? "ENABLE" : "DISABLE")
        DIAG_INFO_UINT32(pos, "ipfix-configure-profile-id", GetDbgIpfixAccInfo0(V, ipfixCfgProfileId_f, &ipfixAccInfo))
        DIAG_INFO_UINT32(pos, "hash-key-type", GetDbgIpfixAccInfo0(V, hashKeyType_f, &ipfixAccInfo))
        DIAG_INFO_UINT32(pos, "hash-field-select-id", GetDbgIpfixAccInfo0(V, flowFieldSel_f, &ipfixAccInfo))

        if(GetDbgIpfixAccInfo0(V, resultValid_f, &ipfixAccInfo))
        {
            value = GetDbgIpfixAccInfo0(V, hashConflict_f, &ipfixAccInfo);
            DIAG_INFO_CHAR(pos, "hash-lookup-result", value ? DIAG_LOOKUP_CONFLICT : DIAG_LOOKUP_HIT)
            DIAG_INFO_UINT32(pos, "key-index", GetDbgIpfixAccInfo0(V, keyIndex_f, &ipfixAccInfo))
        }

        if(GetDbgIpfixAccInfo0(V, samplingEn_f, &ipfixAccInfo))
        {
            value = GetDbgIpfixAccInfo0(V, isSamplingPkt_f, &ipfixAccInfo);
            DIAG_INFO_CHAR(pos, "sample-packet", value ? "TRUE" : "FALSE")
        }
        value = GetDbgIpfixAccInfo0(V, isAddOperation_f, &ipfixAccInfo);
        DIAG_INFO_CHAR(pos, "opration-add", value ? "TRUE" : "FALSE")
        value = GetDbgIpfixAccInfo0(V, isUpdateOperation_f, &ipfixAccInfo);
        DIAG_INFO_CHAR(pos, "opration-update", value ? "TRUE" : "FALSE")
        value = GetDbgIpfixAccInfo0(V, byPassIpfixProcess_f, &ipfixAccInfo);
        DIAG_INFO_CHAR(pos, "opration-bypass", value ? "TRUE" : "FALSE")
        value = GetDbgIpfixAccInfo0(V, denyIpfixInsertOperation_f, &ipfixAccInfo);
        DIAG_INFO_CHAR(pos, "opration-deny-learning", value ? "TRUE" : "FALSE")

        DIAG_INFO_UINT32(pos, "destination-info", GetDbgIpfixAccInfo0(V, destinationInfo_f, &ipfixAccInfo))
        DIAG_INFO_UINT32(pos, "destination-type", GetDbgIpfixAccInfo0(V, destinationType_f, &ipfixAccInfo))
    }
    else
    {
        cmd = DRV_IOR(DbgIpfixAccInfo1_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ipfixAccInfo1));
        if (!GetDbgIpfixAccInfo1(V, valid_f, &ipfixAccInfo1))
        {
            return CTC_E_NONE;
        }
        DIAG_INFO_NONE(pos, "Egress Ipfix Process")
        value =  GetDbgIpfixAccInfo1(V, isUpdateOperation_f, &ipfixAccInfo1);
        DIAG_INFO_CHAR(pos, "opration-update", value ? "TRUE" : "FALSE")
        if (GetDbgIpfixAccInfo1(V, flowIdValid_f, &ipfixAccInfo1))
        {
            DIAG_INFO_UINT32(pos, "flow-id", GetDbgIpfixAccInfo1(V, flowId_f, &ipfixAccInfo1))
        }
        DIAG_INFO_UINT32(pos, "igs-flow-change-cnt", GetDbgIpfixAccInfo1(V, flowChangeCnt_f, &ipfixAccInfo1))
        DIAG_INFO_UINT32(pos, "egs-flow-change-cnt", GetDbgIpfixAccInfo1(V, egressFlowChangeCnt_f, &ipfixAccInfo1))
        DIAG_INFO_UINT32(pos, "cfg-profile-id", GetDbgIpfixAccInfo1(V, ipfixCfgProfileId_f, &ipfixAccInfo1))
        DIAG_INFO_UINT32(pos, "resident-delta", GetDbgIpfixAccInfo1(V, residentDelta_f, &ipfixAccInfo1))
    }

    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_ipe_fcoe_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    DbgIpeFcoeInfo_m fcoe_info;

    sal_memset(&fcoe_info, 0, sizeof(fcoe_info));
    cmd = DRV_IOR(DbgIpeFcoeInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &fcoe_info));
    if (!GetDbgIpeFcoeInfo(V, valid_f, &fcoe_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "FCoE")
    if (GetDbgIpeFcoeInfo(V, fcoeDaResultValid_f, &fcoe_info))
    {
        DIAG_INFO_CHAR(pos, "fcoe-da-result", "HIT")
    }
    if (GetDbgIpeFcoeInfo(V, fcoeSaResultValid_f, &fcoe_info))
    {
        DIAG_INFO_CHAR(pos, "fcoe-sa-result", "HIT")
    }

    /* Drop Process */
    _sys_tmm_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                      GetDbgIpeFcoeInfo(V, discard_f, &fcoe_info),
                                      GetDbgIpeFcoeInfo(V, discardType_f, &fcoe_info));
    /* Exception Process */
    _sys_tmm_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeFcoeInfo(V, exceptionEn_f, &fcoe_info),
                                               GetDbgIpeFcoeInfo(V, exceptionIndex_f, &fcoe_info),
                                               GetDbgIpeFcoeInfo(V, exceptionSubIndex_f, &fcoe_info));
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_ipe_trill_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    DbgIpeTrillInfo_m trill_info;

    sal_memset(&trill_info, 0, sizeof(trill_info));
    cmd = DRV_IOR(DbgIpeTrillInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &trill_info));
    if (!GetDbgIpeTrillInfo(V, valid_f, &trill_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "TRILL")
    if (GetDbgIpeTrillInfo(V, trillResultValid_f, &trill_info))
    {
        DIAG_INFO_CHAR(pos, "trill-result", "HIT")
    }
    else
    {
        DIAG_INFO_CHAR(pos, "trill-result", "HIT-NONE")
    }

    /* Drop Process */
    _sys_tmm_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeTrillInfo(V, discard_f, &trill_info),
                                          GetDbgIpeTrillInfo(V, discardType_f, &trill_info));
    /* Exception Process */
    _sys_tmm_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeTrillInfo(V, exceptionEn_f, &trill_info),
                                               GetDbgIpeTrillInfo(V, exceptionIndex_f, &trill_info),
                                               GetDbgIpeTrillInfo(V, exceptionSubIndex_f, &trill_info));
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_ipe_stmctl_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    char *str_stmctl_type[] = {"Broadcast", "Unknow-Ucast", "Know-Mcast", "Unknow-Mcast"};
    char *str_pkt_type[] = {"None",       "None",         "Ip-Ucast",  "Ip-Mcast",
                            "L2-Ucast",    "L2-Mcast",    "Broadcast", "L2",
                            "Mpls",        "Vpls",        "L3-Vpn",    "Vpws",
                            "Trill-Ucast", "Trill-Mcast", "Fcoe",      "Mpls-Other-Vpn"};
    char *str_know_type[] = {"Uknown-", "Known-"};
    char pkt_type[64]={0};
    char *sys_diag_color[] = {"None", "Red", "Yellow", "Green"};
    DbgIpeFwdStormCtlInfo_m storm_ctl_info;
    IpeStormCtl_m ipe_storm_ctl;
    uint32 stormCtlOffsetSel = 0;
    uint8 storm_ctl_type = 0;

    sal_memset(&storm_ctl_info, 0, sizeof(DbgIpeFwdStormCtlInfo_m));
    cmd = DRV_IOR(DbgIpeFwdStormCtlInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &storm_ctl_info));
    sal_memset(&ipe_storm_ctl, 0, sizeof(IpeStormCtl_m));
    cmd = DRV_IOR(IpeStormCtl_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ipe_storm_ctl));

        /*stormctl*/
    stormCtlOffsetSel = GetDbgIpeFwdStormCtlInfo(V, offsetSel_f, &storm_ctl_info);
    storm_ctl_type = GetIpeStormCtl(V, g_0_ptrOffset_f+stormCtlOffsetSel, &ipe_storm_ctl);
    if(!(GetDbgIpeFwdStormCtlInfo(V, stormCtlEn_f, &storm_ctl_info)
       && GetDbgIpeFwdStormCtlInfo(V, valid_f, &storm_ctl_info)) || 3 < storm_ctl_type)
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    sal_strncat(pkt_type,str_know_type[CTC_IS_BIT_SET(stormCtlOffsetSel, 4)], sizeof(pkt_type)-1);
    sal_strncat(pkt_type,str_pkt_type[CTC_BIT_UNSET(stormCtlOffsetSel, 4)], sizeof(pkt_type)-1);

    DIAG_INFO_NONE(pos, "Storm Control")
    DIAG_INFO_CHAR(pos, "stormctl-color", STR_ARRAY(sys_diag_color,GetDbgIpeFwdStormCtlInfo(V, color_f, &storm_ctl_info)))

    DIAG_INFO_CHAR(pos, "stormctl-type",STR_ARRAY(str_stmctl_type,storm_ctl_type))
    DIAG_INFO_CHAR(pos, "stormctl-pkt-type",pkt_type)
    DIAG_INFO_UINT32(pos, "stormctl-length", GetDbgIpeFwdStormCtlInfo(V, stormCtlLen_f, &storm_ctl_info))

    if (GetDbgIpeFwdStormCtlInfo(V, piStormCtlDrop_f, &storm_ctl_info))
    {
        DIAG_INFO_CHAR(pos, "pi-stormctl-result", "DROP")
    }
    if (GetDbgIpeFwdStormCtlInfo(V, piStormCtlExceptionEn_f, &storm_ctl_info))
    {
        DIAG_INFO_CHAR(pos, "pi-stormctl-result", "EXCEPTION")
    }

    if (GetDbgIpeFwdStormCtlInfo(V, stormCtlDrop_f, &storm_ctl_info))
    {
        DIAG_INFO_CHAR(pos, "stormctl-result", "DROP")
    }
    if (GetDbgIpeFwdStormCtlInfo(V, stormCtlExceptionEn_f, &storm_ctl_info))
    {
        DIAG_INFO_CHAR(pos, "stormctl-result", "EXCEPTION")
    }

    if (GetDbgIpeFwdStormCtlInfo(V, stormCtlPtrValid0_f, &storm_ctl_info))
    {
        DIAG_INFO_UINT32(pos, "stormctl-ptr-0", GetDbgIpeFwdStormCtlInfo(V, stormCtlPtr0_f, &storm_ctl_info))
    }
    if (GetDbgIpeFwdStormCtlInfo(V, stormCtlPtrValid1_f, &storm_ctl_info))
    {
        DIAG_INFO_UINT32(pos, "stormctl-ptr-1", GetDbgIpeFwdStormCtlInfo(V, stormCtlPtr1_f, &storm_ctl_info))
    }

    return CTC_E_NONE;
}
STATIC int32
_sys_tmm_diag_pkt_trace_get_ipe_policer_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint8 port_policerEn[2] = {0};
    uint8 vlan_policerEn[2] = {0};
    uint8 policerValid[2] = {0};
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    DbgIpeFwdPolicingInfo_m policer_info;
    char *sys_diag_color[] = {"None", "Red", "Yellow", "Green"};

    sal_memset(&policer_info, 0, sizeof(DbgIpeFwdPolicingInfo_m));
    cmd = DRV_IOR(DbgIpeFwdPolicingInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &policer_info));

    /*policer*/
    if(!GetDbgIpeFwdPolicingInfo(V, valid_f, &policer_info))
    {
        return CTC_E_NONE;
    }
    port_policerEn[0] = GetDbgIpeFwdPolicingInfo(V, portPolicer0En_f, &policer_info);
    port_policerEn[1] = GetDbgIpeFwdPolicingInfo(V, portPolicer1En_f, &policer_info);
    vlan_policerEn[0] = GetDbgIpeFwdPolicingInfo(V, vlanPolicer0En_f, &policer_info);
    vlan_policerEn[1] = GetDbgIpeFwdPolicingInfo(V, vlanPolicer1En_f, &policer_info);
    policerValid[0] = GetDbgIpeFwdPolicingInfo(V, policerValid0_f, &policer_info);
    policerValid[1] = GetDbgIpeFwdPolicingInfo(V, policerValid1_f, &policer_info);

    if (!(policerValid[0] || policerValid[1]))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "Policing")
    DIAG_INFO_CHAR(pos, "policer-color", STR_ARRAY(sys_diag_color,GetDbgIpeFwdPolicingInfo(V, policerColor_f, &policer_info)))
    DIAG_INFO_UINT32(pos, "policer-length", GetDbgIpeFwdPolicingInfo(V, policerLength_f, &policer_info))
    DIAG_INFO_UINT32(pos, "policer-l3-length", GetDbgIpeFwdPolicingInfo(V, policerLayer3Length_f, &policer_info))
    DIAG_INFO_UINT32(pos, "muxLengthType", GetDbgIpeFwdPolicingInfo(V, muxLengthType_f, &policer_info))
    value = GetDbgIpeFwdPolicingInfo(V, policyProfId_f, &policer_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "policer-profile-id", value)
    }

    if (policerValid[0])
    {
        value = GetDbgIpeFwdPolicingInfo(V, policerPhbEn0_f, &policer_info);
        DIAG_INFO_CHAR(pos, "policer-0-phb", value ? "ENABLE" : "DISABLE")
        if (port_policerEn[0])
        {
            DIAG_INFO_CHAR(pos, "policer-0-port", "ENABLE")
        }
        if (vlan_policerEn[0])
        {
            DIAG_INFO_CHAR(pos, "policer-0-vlan",  "ENABLE")
        }
        DIAG_INFO_UINT32(pos, "policer-0-ptr", GetDbgIpeFwdPolicingInfo(V, policerPtr0_f, &policer_info))
        DIAG_INFO_UINT32(pos, "policer-0-stats-ptr", GetDbgIpeFwdPolicingInfo(V, policerStatsPtr0_f, &policer_info))
    }
    if (policerValid[1])
    {
        DIAG_INFO_CHAR(pos, "policer-1-split", "DISABLE")
        value = GetDbgIpeFwdPolicingInfo(V, policerPhbEn1_f, &policer_info);
        DIAG_INFO_CHAR(pos, "policer-1-phb", value ? "ENABLE" : "DISABLE")
        if (port_policerEn[1])
        {
            DIAG_INFO_CHAR(pos, "policer-1-port", "ENABLE")
        }
        if (vlan_policerEn[1])
        {
            DIAG_INFO_CHAR(pos, "policer-1-vlan", "ENABLE")
        }
        DIAG_INFO_UINT32(pos, "policer-1-ptr", GetDbgIpeFwdPolicingInfo(V, policerPtr1_f, &policer_info))
        DIAG_INFO_UINT32(pos, "policer-1-stats-ptr", GetDbgIpeFwdPolicingInfo(V, policerStatsPtr1_f, &policer_info))
    }
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_ipe_copp_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    DbgIpeFwdCoppInfo_m copp_info;
    char *sys_diag_color[] = {"None", "Red", "Yellow", "Green"};

    sal_memset(&copp_info, 0, sizeof(DbgIpeFwdCoppInfo_m));
    cmd = DRV_IOR(DbgIpeFwdCoppInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &copp_info));

    /*copp*/
    if (!(GetDbgIpeFwdCoppInfo(V, valid_f,&copp_info)
        && GetDbgIpeFwdCoppInfo(V, coppValid_f, &copp_info)))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "CoPP")
    DIAG_INFO_CHAR(pos, "copp-color", STR_ARRAY(sys_diag_color,GetDbgIpeFwdCoppInfo(V, color_f, &copp_info)))
    DIAG_INFO_UINT32(pos, "copp-length", GetDbgIpeFwdCoppInfo(V, coppLen_f, &copp_info))
    DIAG_INFO_UINT32(pos, "copp-ptr", GetDbgIpeFwdCoppInfo(V, coppPtr_f, &copp_info))
    DIAG_INFO_U32_HEX(pos, "copp-stats-ptr", GetDbgIpeFwdCoppInfo(V, coppStatsPtr_f, &copp_info))
    if(GetDbgIpeFwdCoppInfo(V, coppDrop_f, &copp_info))
    {
        DIAG_INFO_CHAR(pos, "copp-result", "DROP")
    }
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_ipe_dest_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
 {
    DbgIpeEcmpProcInfo_m ecmp_info;
    DbgIpeFwdProcessInfo_m fwd_info;
    DbgIpeAclProcInfo0_m   acl_info;
    DbgIpeFwdInputHeaderInfo_m ipe_hdr;
    DbgEcmpDlbEngineInfo_m dlb_info;
    IpePhyPortMuxCtl_m  ipe_phyport;
    DbgIpeUserIdInfo_m user_id_info;

    uint32 cmd = 0;
    uint32 value = 0;
    uint32 rx_oam_type = 0;
    uint32 localPhyPort = 0;
    uint32 hdr_data[SYS_DIAG_HDR_DATA_LENGTH_WORD] = {0};
    uint32 hdr_data_temp[SYS_DIAG_HDR_DATA_LENGTH_WORD] = {0};
    uint32 port_type;
    uint16 extHeaderLen = 0;
    uint16 hdr_len = 48;
    uint8 pos = CTC_DIAG_TRACE_POS_IPE;
    uint8 pos_tmp = CTC_DIAG_TRACE_POS_IPE;
    uint8 legacy_en = 0;
    uint8 copy_hdr_len_word=12;
    uint8 muxType = 0;
    uint32 chan_id = 0;
    uint8 gchip = 0;
    sys_usw_dmps_port_info_t dmps_port_info = {0};

    sal_memset(&ipe_hdr, 0, sizeof(ipe_hdr));
    cmd = DRV_IOR(DbgIpeFwdInputHeaderInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ipe_hdr));
    sal_memset(&ecmp_info, 0, sizeof(ecmp_info));
    cmd = DRV_IOR(DbgIpeEcmpProcInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ecmp_info));
    sal_memset(&fwd_info, 0, sizeof(fwd_info));
    cmd = DRV_IOR(DbgIpeFwdProcessInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &fwd_info));
    sal_memset(&acl_info, 0, sizeof(acl_info));
    cmd = DRV_IOR(DbgIpeAclProcInfo0_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &acl_info));
    cmd = DRV_IOR(DbgIpeOamInfo_t, DbgIpeOamInfo_tempRxOamType_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &rx_oam_type));
    sal_memset(&dlb_info, 0, sizeof(dlb_info));
    cmd = DRV_IOR(DbgEcmpDlbEngineInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &dlb_info));

    if (!GetDbgIpeFwdProcessInfo(V, valid_f,  &fwd_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    DIAG_INFO_NONE(pos, "Destination Processing")


    GetDbgIpeFwdInputHeaderInfo(A, data_f, &ipe_hdr, hdr_data);
    if (sal_memcmp(hdr_data, hdr_data_temp, SYS_DIAG_HDR_DATA_LENGTH_WORD * sizeof(uint32)))
    {
        CTC_ERROR_RETURN(SYS_CB(SYS_CB_STK_GET_STKHDR_VER, lchip, &legacy_en));
        cmd = DRV_IOR(DbgIpeUserIdInfo_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &user_id_info));
        localPhyPort = GetDbgIpeUserIdInfo(V, localPhyPort_f, &user_id_info);
        CTC_ERROR_RETURN(drv_get_gchip_id(lchip, &gchip));
        dmps_port_info.gport = CTC_MAP_LPORT_TO_GPORT(gchip, localPhyPort);
        CTC_ERROR_RETURN(sys_usw_port_api_get_dmps_property(lchip, &dmps_port_info, SYS_PORT_API_DMPS_PROP_CHAN_ID, &chan_id));
        CTC_ERROR_RETURN(sys_usw_port_api_get_dmps_property(lchip, &dmps_port_info, SYS_PORT_API_DMPS_PROP_PORT_TYPE, (void *)&port_type));

        if ((SYS_DMPS_NETWORK_PORT == port_type) ||  (SYS_DMPS_CPUMAC_NETWORK_PORT == port_type))
        {
            cmd = DRV_IOR(IpePhyPortMuxCtl_t, DRV_ENTRY_FLAG);
            CTC_ERROR_RETURN(DRV_IOCTL(lchip,chan_id, cmd, &ipe_phyport));
            muxType = GetIpePhyPortMuxCtl(V, muxType_f, &ipe_phyport);
            /*stacking header 48B or 32B */
            if(DRV_CONST(DRV_STK_MUX_TYPE_HDR_WITH_L2) == muxType|| DRV_CONST(DRV_STK_MUX_TYPE_HDR_WITHOUT_TUNNEL) == muxType)
            {
                if (!legacy_en)
                {
                    /*get CFHeaderBasic extHeaderLen*/
                    extHeaderLen = (hdr_data[11]>>28)&0x7;
                    hdr_len = (16 + (extHeaderLen << 3));
                    copy_hdr_len_word = 12;
                }
                else
                {
                    hdr_len = SYS_DIAG_BASIC_STACKING_HEADER_LEN;
                    copy_hdr_len_word = 8;
                }
            } 
        }
        CTC_ERROR_RETURN(sys_usw_dword_reverse_copy(hdr_data_temp,hdr_data,copy_hdr_len_word));
        sys_usw_swap32(hdr_data_temp, copy_hdr_len_word, FALSE);
        DIAG_INFO_PKT_HDR(pos, "packet-header", hdr_data_temp,hdr_len)
    }

    value = GetDbgIpeEcmpProcInfo(V, ecmpGroupId_f, &ecmp_info);
    if (GetDbgIpeEcmpProcInfo(V, ecmpEn_f, &ecmp_info)
        && GetDbgIpeEcmpProcInfo(V, valid_f, &ecmp_info)
        && value)
    {
        DIAG_INFO_CHAR(pos, "dest-type", "ECMP")
        DIAG_INFO_UINT32(pos, "ecmp-group", value)
        DIAG_INFO_CHAR(pos, "ecmp-stage1", GetDbgIpeEcmpProcInfo(V, ecmpStage1En_f, &ecmp_info)? DIAG_ENABLE: DIAG_DISABLE)
        DIAG_INFO_CHAR(pos, "ecmp-stage2", GetDbgIpeEcmpProcInfo(V, ecmpStage2En_f, &ecmp_info)? DIAG_ENABLE: DIAG_DISABLE)
        DIAG_INFO_CHAR(pos, "ecmp-lsh", GetDbgIpeEcmpProcInfo(V, ecmpLinkSelfHealingEn_f, &ecmp_info)? DIAG_ENABLE: DIAG_DISABLE)
        DIAG_INFO_UINT32(pos, "hash-value0", GetDbgIpeEcmpProcInfo(V, hashValue0_f, &ecmp_info))
        DIAG_INFO_UINT32(pos, "hash-value1", GetDbgIpeEcmpProcInfo(V, hashValue1_f, &ecmp_info))

        if (GetDbgIpeEcmpProcInfo(V, antFlowPathValid_f, &ecmp_info))
        {
            DIAG_INFO_CHAR(pos, "antFlowEn", DIAG_ENABLE)
            DIAG_INFO_UINT32(pos, "active", GetDbgIpeEcmpProcInfo(V, antFlowActive_f, &ecmp_info))
            DIAG_INFO_UINT32(pos, "link-state", GetDbgIpeEcmpProcInfo(V, antFlowLinkState_f, &ecmp_info))
            DIAG_INFO_UINT32(pos, "path-valid", 1)
            DIAG_INFO_U32_HEX(pos, "record-info", GetDbgIpeEcmpProcInfo(V, antFlowRecordInfo_f, &ecmp_info))
        }
        if (GetDbgEcmpDlbEngineInfo(V, valid_f, &dlb_info))
        {
            if (GetDbgEcmpDlbEngineInfo(V, isUpdateOperation_f, &dlb_info))
            {
                DIAG_INFO_CHAR(pos, "flow-state", DIAG_LOOKUP_HIT)
                if (GetDbgEcmpDlbEngineInfo(V, rebalance_f, &dlb_info))
                {
                    DIAG_INFO_CHAR(pos, "rebalance", DIAG_YES)
                    DIAG_INFO_CHAR(pos, "force-rebalance", GetDbgEcmpDlbEngineInfo(V, memberSelChangeForceReb_f, &dlb_info)? DIAG_YES: DIAG_NO)
                    DIAG_INFO_CHAR(pos, "rebalance-ready", GetDbgEcmpDlbEngineInfo(V, rebalanceReady_f, &dlb_info)? DIAG_YES: DIAG_NO)
                    DIAG_INFO_UINT32(pos, "rebalance-cnt", GetDbgEcmpDlbEngineInfo(V, rebalanceCount_f, &dlb_info))
                }
                else
                {
                    DIAG_INFO_CHAR(pos, "rebalance", DIAG_NO)
                    DIAG_INFO_CHAR(pos, "disable-rebalance", GetDbgEcmpDlbEngineInfo(V, disableRebalance_f, &dlb_info)? DIAG_YES: DIAG_NO)
                    DIAG_INFO_CHAR(pos, "rebalance-ready", GetDbgEcmpDlbEngineInfo(V, rebalanceReady_f, &dlb_info)? DIAG_YES: DIAG_NO)
                    DIAG_INFO_CHAR(pos, "all-link-down", GetDbgEcmpDlbEngineInfo(V, allSelectLinkDown_f, &dlb_info)? DIAG_YES: DIAG_NO)
                }
            }
            else if (GetDbgEcmpDlbEngineInfo(V, isConflictOperation_f, &dlb_info))
            {
                DIAG_INFO_CHAR(pos, "flow-state", DIAG_LOOKUP_CONFLICT)
            }
            else
            {
                DIAG_INFO_CHAR(pos, "flow-state", DIAG_LOOKUP_HIT_NONE)
            }
        }
        p_rslt->ecmp_group = value;
        p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_ECMP_GROUP;
    }

    if (GetDbgIpeAclProcInfo0(V, apsBridgeValid0_f, &acl_info))
    {
        DIAG_INFO_CHAR(pos, "dest-type", "APS")
        DIAG_INFO_UINT32(pos, "aps-group-1st-level", GetDbgIpeAclProcInfo0(V, apsBridgeIndex0_f, &acl_info))
        if (GetDbgIpeAclProcInfo0(V, apsBridgeValid1_f,  &acl_info))
        {
            DIAG_INFO_UINT32(pos, "aps-group-2nd-level", GetDbgIpeAclProcInfo0(V, apsBridgeIndex1_f, &acl_info))
        }
    }
    else
    {
        if (GetDbgIpeAclProcInfo0(V, apsSelectValid0_f,  &acl_info))
        {
            DIAG_INFO_UINT32(pos, "aps-group-select-0", GetDbgIpeAclProcInfo0(V, apsSelectGroupId0_f, &acl_info))
        }
        if (GetDbgIpeAclProcInfo0(V, apsSelectValid1_f,  &acl_info))
        {
            DIAG_INFO_UINT32(pos, "aps-group-select-1", GetDbgIpeAclProcInfo0(V, apsSelectGroupId1_f, &acl_info))
        }
    }

    if (rx_oam_type)
    {
        DIAG_INFO_CHAR(pos, "dest-type", "OAM")
        p_rslt->dest_type = CTC_DIAG_DEST_OAM;
        CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_oam_rx_info(lchip, p_rslt));
    }
    else
    {
        uint32 fwd_destMap = GetDbgIpeFwdProcessInfo(V, destMap_f,  &fwd_info);
        uint8  int_op_type = GetDbgIpeFwdProcessInfo(V, intOpType_f,  &fwd_info);
        uint8  acl_dscp_valid = GetDbgIpeFwdProcessInfo(V, aclDscpValid_f,  &fwd_info);
        uint8  src_dscp_valid = GetDbgIpeFwdProcessInfo(V, srcDscpValid_f,  &fwd_info);
        char* const int_type_desc[] = {"", "SOURCE", "TRANSIT", "SINK"};

        DIAG_INFO_CHAR(pos, "bypass-ipe", GetDbgIpeFwdProcessInfo(V, bypassIpe_f,  &fwd_info) ? "Yes" : "No")
        if (acl_dscp_valid && src_dscp_valid)
        {
            DIAG_INFO_CHAR(pos, "dscp-valid", "from acl")
        }
        else if (src_dscp_valid)
        {
            DIAG_INFO_CHAR(pos, "dscp-valid", "from src")
        }
        /*INT*/
        if (0 != int_op_type)
        {
            DIAG_INFO_CHAR(pos, "int-op-type", STR_ARRAY(int_type_desc,int_op_type))
            DIAG_INFO_U32_HEX(pos, "int-op-ptr", GetDbgIpeFwdProcessInfo(V, intOpPtr_f,  &fwd_info))
            if (GetDbgIpeFwdProcessInfo(V, intIgrLog_f,  &fwd_info))
            {
                DIAG_INFO_UINT32(pos, "int-log-block", GetDbgIpeFwdProcessInfo(V, intIgrLogBlock_f,  &fwd_info))
                DIAG_INFO_UINT32(pos, "int-log-id", GetDbgIpeFwdProcessInfo(V, intIgrLogId_f,  &fwd_info))
            }
        }

        if (GetDbgIpeFwdProcessInfo(V, discard_f, &fwd_info) || (0x3FFFF == GetDbgIpeFwdProcessInfo(V, nextHopPtr_f,  &fwd_info)))
        {
            DIAG_INFO_CHAR(pos, "dest-type", "DROP")
            p_rslt->dest_type = CTC_DIAG_DEST_DROP;
        }
        else if (CTC_IS_BIT_SET(fwd_destMap, 18))/* Mcast */
        {
            DIAG_INFO_CHAR(pos, "dest-type", "Mcast Group")
            DIAG_INFO_UINT32(pos, "mcast-group", fwd_destMap&0xFFFF)
            p_rslt->mc_group = fwd_destMap&0xFFFF;
            p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_MC_GROUP;
        }
        else
        {
            uint32 dest_chip = (fwd_destMap >> 9)&0x7F;
            if (CTC_IS_BIT_SET(fwd_destMap, 16))/* fwd to cpu */
            {
                DIAG_INFO_CHAR(pos, "dest-type", "CPU")
                p_rslt->port =  CTC_GPORT_RCPU(dest_chip);
                p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_PORT;
                p_rslt->dest_type = CTC_DIAG_DEST_CPU;
            }
            else
            {
                if (dest_chip == 0x1F) /* Linkagg */
                {
                    p_rslt->dest_type = CTC_DIAG_DEST_NETWORK;
                    p_rslt->tid =  fwd_destMap&CTC_LINKAGGID_MASK;
                    p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_TID;
                    DIAG_INFO_CHAR(pos, "dest-type", "Linkagg Port")
                    DIAG_INFO_UINT32(pos, "linkagg-group", p_rslt->tid)
                }
                else
                {
                    value = SYS_MAP_DRV_LPORT_TO_CTC_GPORT(dest_chip, fwd_destMap&0x1FF);
                    p_rslt->port =  value;
                    p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_PORT;
                    p_rslt->dest_type = CTC_DIAG_DEST_NETWORK;
                    DIAG_INFO_CHAR(pos, "dest-type", "Network Port")
                    DIAG_INFO_U32_HEX(pos, "network-port", value)
                }
/*
                cmd = DRV_IOR(EpeHdrAdjustCtl_t, EpeHdrAdjustCtl_dsNextHopInternalBase_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
*/
                DIAG_INFO_CHAR(pos, "nexthop-lookup-result", DIAG_LOOKUP_HIT)
                DIAG_INFO_U32_HEX(pos,"nexthop-ptr", GetDbgIpeFwdProcessInfo(V, nextHopPtr_f,  &fwd_info))
                /*
                if (((GetDbgIpeFwdProcessInfo(V, nextHopPtr_f,  &fwd_info) >> 4)&0x3FFF) != value)
                {
                    DIAG_INFO_CHAR(pos, "table-name", GetDbgIpeFwdProcessInfo(V, nextHopExt_f,  &fwd_info) ? "DsNextHop8W" : "DsNextHop4W")

                }
                else
                {
                    DIAG_INFO_CHAR(pos, "table-name", "EpeNextHopInternal")
                    DIAG_INFO_UINT32(pos,"table-index", (GetDbgIpeFwdProcessInfo(V, nextHopPtr_f,  &fwd_info)&0xF) >> 1)
                }
                */
            }
        }
    }

    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipfix_info(lchip, p_rslt, 0));

	pos_tmp = p_rslt->position;
	p_rslt->position = CTC_DIAG_TRACE_POS_IPE;
    /* Drop Process */
    _sys_tmm_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgIpeFwdProcessInfo(V, discard_f, &fwd_info),
                                          GetDbgIpeFwdProcessInfo(V, discardType_f,  &fwd_info));
    /* Exception Process */
    _sys_tmm_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgIpeFwdProcessInfo(V, exceptionEn_f, &fwd_info),
                                               GetDbgIpeFwdProcessInfo(V, exceptionIndex_f, &fwd_info),
                                               GetDbgIpeFwdProcessInfo(V, exceptionSubIndex_f, &fwd_info));
	p_rslt->position = pos_tmp;
     return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_epe_scl_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 key_data[DIAF_EGS_SCL_KEY_SIZE] = {0};
    uint8  pos = CTC_DIAG_TRACE_POS_EPE;
    uint8  loop = 0;
    uint8  hash_hit = 0;
    uint8  dft_hit = 0;
    uint8  lkup_en[2] = {0};
    uint8  hash_type[2] = {0};
    const char* key_name[] ={
        "DISABLE",          "DOUBLEVLANPORT",
        "SVLANPORT",        "CVLANPORT",
        "SVLANCOSPORT",     "CVLANCOSPORT",
        "PORTVLANCROSS",    "PORTCROSS",
        "PORT",             "SVLANPORTMAC",
        "FIDDVP",           "FIDDVPGROUP",
        "FID",              "METADATADVPGROUP",
        "I2ECIDDVPGROUP",   "METADATADVP"
    };
    DbgEgrSclHash0_m egr_scl_info[2];
    DbgEpeNextHopInfo_m next_hop_info;

    cmd = DRV_IOR(DbgEgrSclHash0_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &egr_scl_info[0]));
    cmd = DRV_IOR(DbgEgrSclHash1_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &egr_scl_info[1]));
    cmd = DRV_IOR(DbgEpeNextHopInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &next_hop_info));

    if (!GetDbgEpeNextHopInfo(V, valid_f, &next_hop_info))
    {
        return CTC_E_NONE;
    }
    if (!GetDbgEgrSclHash0(V, valid_f, &egr_scl_info[0]) &&
        !GetDbgEgrSclHash1(V, valid_f, &egr_scl_info[1]))
    {
        return CTC_E_NONE;
    }

    lkup_en[0] = GetDbgEpeNextHopInfo(V, lookup0Valid_f, &next_hop_info);
    lkup_en[1] = GetDbgEpeNextHopInfo(V, lookup1Valid_f, &next_hop_info);
    hash_type[0] = GetDbgEpeNextHopInfo(V, vlanHash0Type_f, &next_hop_info);
    hash_type[1] = GetDbgEpeNextHopInfo(V, vlanHash1Type_f, &next_hop_info);
    p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
    DIAG_INFO_NONE(pos, "SCL Process")
    for (loop=0; loop<2; loop++)
    {
        hash_hit = GetDbgEgrSclHash0(V, resultValid_f, &egr_scl_info[loop]);
        dft_hit = GetDbgEgrSclHash0(V, defaultEntryValid_f, &egr_scl_info[loop]);
        if (lkup_en[loop] && hash_hit && !dft_hit)
        {
            DIAG_INFO_CHAR(pos, loop? "hash-1-lookup-result": "hash-0-lookup-result", DIAG_LOOKUP_HIT)
            DIAG_INFO_CHAR(pos, "key-name", STR_ARRAY(key_name,hash_type[loop]))
            DIAG_INFO_UINT32(pos, "key-index", GetDbgEgrSclHash0(V, keyIndex_f, &egr_scl_info[loop]))
        }
        else if (lkup_en[loop])
        {
            DIAG_INFO_CHAR(pos, loop? "hash-1-lookup-result": "hash-0-lookup-result", hash_hit? DIAG_LOOKUP_DEFAULT: DIAG_LOOKUP_HIT_NONE)
            DIAG_INFO_CHAR(pos, "key-name",  STR_ARRAY(key_name,hash_type[loop]))
            DIAG_INFO_U32_HEX(pos, "key-index", GetDbgEgrSclHash0(V, keyIndex_f, &egr_scl_info[loop]))
            GetDbgEgrSclHash0(A, lookupKey_f, &egr_scl_info[loop], key_data);
            DIAG_INFO_U32_LIST(pos, "key-data", key_data, DIAF_EGS_SCL_KEY_SIZE)
        }
    }
    return CTC_E_NONE;
}


STATIC int32
_sys_tmm_diag_pkt_trace_get_epe_hdj_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint32 nhp_nhpIs8w = 0;
    uint32 dsNextHopInternalBase = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    char* vlanTagAction[] = {"None", "Add", "Remove", "Replace"};
    char* str_opType[] = {"NORMAL", "LTMX", "E2ILOOP", "DMTX", "C2C", "PTP", "NAT", "OAM"};
    DbgEpeHdrAdjInfo_m hdr_info;
    DbgEpeHdrAdjInfo0_m hdr_info0;

    cmd = DRV_IOR(DbgEpeHdrAdjInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &hdr_info));
    cmd = DRV_IOR(DbgEpeHdrAdjInfo0_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &hdr_info0));
    cmd = DRV_IOR(EpeHdrAdjustCtl_t, EpeHdrAdjustCtl_dsNextHopInternalBase_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &dsNextHopInternalBase));
    cmd = DRV_IOR(DbgEpeNextHopInfo_t, DbgEpeNextHopInfo_nhpIs8w_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &nhp_nhpIs8w));


    if (!GetDbgEpeHdrAdjInfo(V, valid_f, &hdr_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
    DIAG_INFO_NONE(pos, "EPE Header Adjust")

    value = GetDbgEpeHdrAdjInfo(V, channelId_f, &hdr_info);
    DIAG_INFO_UINT32(pos, "channel-id", value)
    if (!CTC_FLAG_ISSET(p_rslt->flags, CTC_DIAG_TRACE_RSTL_FLAG_MC_GROUP))
    {
        p_rslt->channel = value;
        p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_CHANNLE;
    }
    if (value == MCHIP_CAP(SYS_CAP_CHANID_ILOOP))
    {
        p_rslt->loop_flags |= CTC_DIAG_LOOP_FLAG_ILOOP;
    }
    if (value == MCHIP_CAP(SYS_CAP_CHANID_ELOOP))
    {
        p_rslt->loop_flags |= CTC_DIAG_LOOP_FLAG_ELOOP;
    }

    if (GetDbgEpeHdrAdjInfo0(V, valid_f, &hdr_info0))
    {
        DIAG_INFO_CHAR(pos, "dest-select", GetDbgEpeHdrAdjInfo0(V, destSelect_f, &hdr_info0)? "To-CPU": "Normal")
        DIAG_INFO_UINT32(pos, "queue-id", GetDbgEpeHdrAdjInfo0(V, queueId_f, &hdr_info0))
        DIAG_INFO_UINT32(pos, "color", GetDbgEpeHdrAdjInfo0(V, reColor_f, &hdr_info0))
        if (GetDbgEpeHdrAdjInfo0(V, cutThroughEn_f, &hdr_info0))
        {
            DIAG_INFO_CHAR(pos, "cut-through", DIAG_ENABLE)
        }
        if (GetDbgEpeHdrAdjInfo0(V, bypassMacsecProc_f, &hdr_info0))
        {
            DIAG_INFO_CHAR(pos, "cancel-dot1ae", DIAG_YES);
        }
        if (GetDbgEpeHdrAdjInfo0(V, destIdDiscard_f, &hdr_info0))
        {
            DIAG_INFO_CHAR(pos, "drop-desc", "dest-id-discard")
        }
    }

    DIAG_INFO_UINT32(pos, "local-phy-port", GetDbgEpeHdrAdjInfo(V, localPhyPort_f, &hdr_info))
    if (!GetDbgEpeHdrAdjInfo(V, bypassAll_f, &hdr_info) && !GetDbgEpeHdrAdjInfo(V, bypassEpe_f, &hdr_info))
    {
        value = GetDbgEpeHdrAdjInfo(V, nextHopPtr_f, &hdr_info);
        DIAG_INFO_U32_HEX(pos, "nexthop-ptr", value)
        if ((value >> 4) != dsNextHopInternalBase)
        {
            DIAG_INFO_CHAR(pos, "nexthop-table-name", nhp_nhpIs8w? "DsNextHop8W" : "DsNextHop4W")
            DIAG_INFO_UINT32(pos, "nexthop-table-index", value)
        }
        else
        {
            DIAG_INFO_CHAR(pos, "nexthop-table-name",  "EpeNextHopInternal")
            DIAG_INFO_UINT32(pos, "nexthop-table-index", (value & 0xF) >> 1)
        }
    }
    DIAG_INFO_UINT32(pos, "mux-length-type", GetDbgEpeHdrAdjInfo(V, muxLengthType_f, &hdr_info))
    value = GetDbgEpeHdrAdjInfo(V, packetOffset_f, &hdr_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "strip-packet(bytes)", value)
    }
    DIAG_INFO_UINT32(pos, "packet-length-adjust", GetDbgEpeHdrAdjInfo(V, packetLengthAdjust_f, &hdr_info))
    DIAG_INFO_UINT32(pos, "packet-length-adjust-type", GetDbgEpeHdrAdjInfo(V, packetLengthAdjustType_f, &hdr_info))
    DIAG_INFO_CHAR(pos, "operation-type", STR_ARRAY(str_opType,GetDbgEpeHdrAdjInfo(V, operationType_f, &hdr_info)))
    if (GetDbgEpeHdrAdjInfo(V, svlanTagOperationValid_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "svlan-action", STR_ARRAY(vlanTagAction,GetDbgEpeHdrAdjInfo(V, sTagAction_f, &hdr_info)))
    }
    if (GetDbgEpeHdrAdjInfo(V, cvlanTagOperationValid_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "cvlan-action", STR_ARRAY(vlanTagAction,GetDbgEpeHdrAdjInfo(V, cTagAction_f, &hdr_info)))
    }
    if (GetDbgEpeHdrAdjInfo(V, isSendtoCpuEn_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "send-to-cpu", "TRUE")
    }
    if (GetDbgEpeHdrAdjInfo(V, fromFabric_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-from-fabric", "TRUE")
    }
    if (GetDbgEpeHdrAdjInfo(V, pktWithCidHeader_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "packet-with-cid-header", "TRUE")
    }
    if (GetDbgEpeHdrAdjInfo(V, bypassAll_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "egress-edit-bypass-all", "TRUE")
    }
    if (GetDbgEpeHdrAdjInfo(V, ingressEditNexthopBypassAll_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "ingress-edit-bypass-all", "TRUE")
    }
    if (GetDbgEpeHdrAdjInfo(V, bypassIpe_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "bypass-ipe", DIAG_YES)
    }
    if (GetDbgEpeHdrAdjInfo(V, bypassEpe_f, &hdr_info))
    {
        DIAG_INFO_CHAR(pos, "bypass-epe", DIAG_YES)
    }

    /* Drop Process */
    _sys_tmm_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgEpeHdrAdjInfo(V, discard_f, &hdr_info),
                                          GetDbgEpeHdrAdjInfo(V, discardType_f,  &hdr_info));
    return CTC_E_NONE;
}



STATIC int32
_sys_tmm_diag_pkt_trace_get_epe_acl_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 idx = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    char* acl_key_type_desc[] = {"TCAML2KEY", "TCAMl3KEY", "TCAML3EXTKEY", "TCAMIPV6KEY", "TCAMIPV6EXTKEY", "TCAMUDFKEY",  "TCAML2L3KEY",
                                 "TCAML2IPV6KEY", "TCAMCIDKEY", "TCAMINTFKEY", "TCAMFWDKEY", "TCAMFWDEXT", "TCAMCOPPKEY", "TCAMCOPPEXTKEY",  "TCAML2L3KEYEXT"};
    DbgFlowTcamEngineEpeAclInfo_m epe_acl_info;
    DbgFlowTcamEngineEpeAclKeyInfo0_m dbg_acl_key_info;
    uint32 acl_key_info_key_id[4] = {DbgFlowTcamEngineEpeAclKeyInfo0_t, DbgFlowTcamEngineEpeAclKeyInfo1_t,
                                     DbgFlowTcamEngineEpeAclKeyInfo2_t, DbgFlowTcamEngineEpeAclKeyInfo3_t};
    DbgEpeAclInfo_m dbg_epe_acl_info;

    cmd = DRV_IOR(DbgFlowTcamEngineEpeAclInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &epe_acl_info));
    sal_memset(&dbg_epe_acl_info, 0, sizeof(dbg_epe_acl_info));
    cmd = DRV_IOR(DbgEpeAclInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &dbg_epe_acl_info));

    if (!GetDbgEpeAclInfo(V, valid_f, &dbg_epe_acl_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
    DIAG_INFO_NONE(pos, "Egress ACL/TCAM Processing")



    /*tcam*/
    if (GetDbgFlowTcamEngineEpeAclInfo(V, valid_f, &epe_acl_info))
    {

        char* lookup_result[] = {"TCAM0-lookup-result", "TCAM1-lookup-result",
                                  "TCAM2-lookup-result", "TCAM3-lookup-result"};
                    
        uint8 lkup_en[4] = {GetDbgEpeAclInfo(V, gAclLkp_0_lookupEn_f, &dbg_epe_acl_info),
                                  GetDbgEpeAclInfo(V, gAclLkp_1_lookupEn_f, &dbg_epe_acl_info),
                                  GetDbgEpeAclInfo(V, gAclLkp_2_lookupEn_f, &dbg_epe_acl_info),
                                  GetDbgEpeAclInfo(V, gAclLkp_3_lookupEn_f, &dbg_epe_acl_info)};

        uint32 result_valid[4] = {GetDbgFlowTcamEngineEpeAclInfo(V, gAclLookup_0_resultValid_f, &epe_acl_info),
                                  GetDbgFlowTcamEngineEpeAclInfo(V, gAclLookup_1_resultValid_f, &epe_acl_info),
                                  GetDbgFlowTcamEngineEpeAclInfo(V, gAclLookup_2_resultValid_f, &epe_acl_info),
                                  GetDbgFlowTcamEngineEpeAclInfo(V, gAclLookup_3_resultValid_f, &epe_acl_info)};
        uint32 tcam_index[4] = {GetDbgFlowTcamEngineEpeAclInfo(V, gAclLookup_0_hitIndex_f, &epe_acl_info),
                                GetDbgFlowTcamEngineEpeAclInfo(V, gAclLookup_1_hitIndex_f, &epe_acl_info),
                                GetDbgFlowTcamEngineEpeAclInfo(V, gAclLookup_2_hitIndex_f, &epe_acl_info),
                                GetDbgFlowTcamEngineEpeAclInfo(V, gAclLookup_3_hitIndex_f, &epe_acl_info)};
        uint32 acl_key_info[20] = {0};
        uint32 acl_key_valid = 0;
        uint32 acl_key_size = 1;  /* 0:80bit; 1:160bit; 2:320bit; 3:640bit */
        uint32 key_index = 0;
        uint32 acl_key_type = 0;

        for (idx = 0; idx < 4 ; idx++)
        {
            if (!lkup_en[idx])
            {  
                continue;
            }
            cmd = DRV_IOR(acl_key_info_key_id[idx], DRV_ENTRY_FLAG);
            CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &dbg_acl_key_info));
            DRV_GET_FIELD_A(lchip, acl_key_info_key_id[idx], ((3 == idx) ? DbgFlowTcamEngineEpeAclKeyInfo3_key_f : DbgFlowTcamEngineEpeAclKeyInfo0_key_f),
                            &dbg_acl_key_info, &acl_key_info);
            DRV_GET_FIELD_A(lchip, acl_key_info_key_id[idx], ((3 == idx) ? DbgFlowTcamEngineEpeAclKeyInfo3_valid_f : DbgFlowTcamEngineEpeAclKeyInfo0_valid_f),
                            &dbg_acl_key_info, &acl_key_valid);
            DRV_GET_FIELD_A(lchip, acl_key_info_key_id[idx], ((3 == idx) ? DbgFlowTcamEngineEpeAclKeyInfo3_keySize_f : DbgFlowTcamEngineEpeAclKeyInfo0_keySize_f),
                            &dbg_acl_key_info, &acl_key_size);

            if (result_valid[idx])
            {
                DIAG_INFO_CHAR(pos, lookup_result[idx], DIAG_LOOKUP_HIT)
                _sys_tmm_diag_map_tcam_key_index(lchip, tcam_index[idx], 1, idx, &key_index);
                DIAG_INFO_UINT32(pos, "key-index", (key_index / (1<<(acl_key_size-1))))
                DIAG_INFO_UINT32(pos, "key-size", 80*(1<<acl_key_size))
            }
            else
            {
                DIAG_INFO_CHAR(pos, lookup_result[idx], DIAG_LOOKUP_HIT_NONE)
            }
            /*get key type*/
            if(!acl_key_valid)
            {
                continue;
            }
            acl_key_type = GetDsAclQosL3Key320Egr0(V, aclQosKeyType0_f, &acl_key_info);
            DIAG_INFO_CHAR(pos, "key-type", STR_ARRAY(acl_key_type_desc,acl_key_type))

        }
    }


    /* Exception Process */
    _sys_tmm_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgEpeAclInfo(V, exceptionEn_f, &dbg_epe_acl_info),
                                               GetDbgEpeAclInfo(V, exceptionIndex_f, &dbg_epe_acl_info),
                                               GetDbgEpeAclInfo(V, exceptionSubIndex_f, &dbg_epe_acl_info));
    return CTC_E_NONE;
}
STATIC int32
_sys_tmm_diag_pkt_trace_get_epe_copp_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    DbgEpeCoPPInfo_m copp_info;
    char *sys_diag_color[] = {"None", "Red", "Yellow", "Green"};

    cmd = DRV_IOR(DbgEpeCoPPInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &copp_info));

    /*copp*/
    if (!(GetDbgEpeCoPPInfo(V, valid_f,&copp_info)
        && GetDbgEpeCoPPInfo(V, coppValid_f, &copp_info)))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
    DIAG_INFO_NONE(pos, "CoPP")
    DIAG_INFO_CHAR(pos, "copp-color", STR_ARRAY(sys_diag_color,GetDbgEpeCoPPInfo(V, color_f, &copp_info)))
    DIAG_INFO_UINT32(pos, "copp-length", GetDbgEpeCoPPInfo(V, coppLen_f, &copp_info))
    DIAG_INFO_UINT32(pos, "copp-ptr", GetDbgEpeCoPPInfo(V, coppPtr_f, &copp_info))
    DIAG_INFO_U32_HEX(pos, "copp-stats-ptr", GetDbgEpeCoPPInfo(V, coppStatsPtr_f, &copp_info))
    if(GetDbgEpeCoPPInfo(V, coppDrop_f, &copp_info))
    {
        DIAG_INFO_CHAR(pos, "copp-result", "DROP")
    }
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_epe_nh_map_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    uint32 value = 0;
    uint32 gport = 0;
    char* str_pl_op[] = {"NONE", "ROUTE", "BRIDGE", "BRIDGE-VPLS", "BRIDGE-INNER", "MIRROR", "ROUTE-NOTTL", "ROUTE-COMPACT"};
    DbgEpeNextHopInfo_m nh_info;

    sal_memset(&nh_info, 0, sizeof(DbgEpeNextHopInfo_m));
    cmd = DRV_IOR(DbgEpeNextHopInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &nh_info));
    if (!GetDbgEpeNextHopInfo(V, valid_f, &nh_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
    DIAG_INFO_NONE(pos, "NextHop Mapper");

    cmd = DRV_IOR(DbgEpeHdrAdjInfo_t, DbgEpeHdrAdjInfo_valid_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
    if (value)
    {
        cmd = DRV_IOR(DbgEpeHdrAdjInfo_t, DbgEpeHdrAdjInfo_localPhyPort_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
        cmd = DRV_IOR(DsDestPort_t, DsDestPort_globalDestPort_f);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, value, cmd, &gport));
        if (SYS_DRV_IS_LINKAGG_PORT(gport))
        {
            DIAG_INFO_UINT32(pos, "linkagg-group", gport&0xFF)
        }
        DIAG_INFO_U32_HEX(pos, "dest-gport", SYS_MAP_DRV_GPORT_TO_CTC_GPORT(gport))
        p_rslt->dest_type = (value == MCHIP_CAP(SYS_CAP_RSV_PORT_TO_CPU)) ? CTC_DIAG_DEST_CPU : CTC_DIAG_DEST_NETWORK;
        p_rslt->port = SYS_MAP_DRV_GPORT_TO_CTC_GPORT(gport);
        p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_PORT;
    }
    DIAG_INFO_UINT32(pos, "bypass-epe", GetDbgEpeNextHopInfo(V, bypassEpe_f, &nh_info))
    DIAG_INFO_UINT32(pos, "is-link-oam", GetDbgEpeNextHopInfo(V, linkOam_f, &nh_info))
    DIAG_INFO_UINT32(pos, "strip-l2-hdr", GetDbgEpeNextHopInfo(V, stripL2Hdr_f, &nh_info))
    if (GetDbgEpeNextHopInfo(V, nhpCategoryValid_f, &nh_info))
    {
        DIAG_INFO_UINT32(pos, "nhp-category-id", GetDbgEpeNextHopInfo(V, nhpCategoryId_f, &nh_info))
    }
    if (GetDbgEpeNextHopInfo(V, policerValid0_f, &nh_info))
    {
        DIAG_INFO_UINT32(pos, "policer-ptr-0", GetDbgEpeNextHopInfo(V, policerPtr0_f, &nh_info))
    }
    if (GetDbgEpeNextHopInfo(V, policerValid1_f, &nh_info))
    {
        DIAG_INFO_UINT32(pos, "policer-ptr-1", GetDbgEpeNextHopInfo(V, policerPtr1_f, &nh_info))
    }
    value = GetDbgEpeNextHopInfo(V, destVlanPtr_f, &nh_info);
    DIAG_INFO_UINT32(pos, "vlan-ptr", value)

    if (GetDbgEpeNextHopInfo(V, outputSvlanIdValid_f, &nh_info))
    {
        DIAG_INFO_UINT32(pos, "output-svlan", GetDbgEpeNextHopInfo(V, outputSvlanId_f, &nh_info))
    }
    if (GetDbgEpeNextHopInfo(V, outputCvlanIdValid_f, &nh_info))
    {
        DIAG_INFO_UINT32(pos, "output-cvlan", GetDbgEpeNextHopInfo(V, outputCvlanId_f, &nh_info))
    }
    value = GetDbgEpeNextHopInfo(V, interfaceId_f, &nh_info);
    if (value)
    {
        p_rslt->l3if_id = value;
        p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_L3IF_ID;
        DIAG_INFO_UINT32(pos, "interface-id", value)
    }
    value = GetDbgEpeNextHopInfo(V, logicDestPort_f, &nh_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "logic-port", value)
    }
    if (GetDbgEpeNextHopInfo(V, nextApsBridgeEn_f, &nh_info))
    {
        DIAG_INFO_UINT32(pos, "next-aps-group", GetDbgEpeNextHopInfo(V, nextApsGroupId_f, &nh_info))
    }
    DIAG_INFO_CHAR(pos, "payload-opration",STR_ARRAY(str_pl_op,GetDbgEpeNextHopInfo(V, payloadOperation_f, &nh_info)))
    if (GetDbgEpeNextHopInfo(V, portLogEn_f, &nh_info))
    {
        DIAG_INFO_CHAR(pos, "port-log", "ENABLE")
    }
    if (GetDbgEpeNextHopInfo(V, portIsolateValid_f, &nh_info))
    {
        DIAG_INFO_CHAR(pos, "port-isolate", "ENABLE")
    }

    /* Drop Process */
    _sys_tmm_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgEpeNextHopInfo(V, discard_f, &nh_info),
                                          GetDbgEpeNextHopInfo(V, discardType_f,  &nh_info));
    /* Exception Process */
    _sys_tmm_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgEpeNextHopInfo(V, exceptionEn_f, &nh_info),
                                               GetDbgEpeNextHopInfo(V, exceptionIndex_f, &nh_info),
                                               GetDbgEpeNextHopInfo(V, exceptionSubIndex_f, &nh_info));
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_epe_oam_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint8 idx = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    uint32 value = 0;
    uint32 hdr_shareType = 0;
    char* lookup_result[] = {"ETHER", "BFD", "TP", "Section"};
    char* key_name[] = {"DsOamEthHashKey", "DsOamBfdHashKey",
                         "DsOamMplsLabelHashKey", "DsOamMplsSectionHashKey"};
    char *sys_diag_color[] = {"None", "Red", "Yellow", "Green"};

    DbgOamHashEngineFromEpeOam0Info_m epe_oam0_info;
    DbgOamHashEngineFromEpeOam1Info_m epe_oam1_info;
    DbgOamHashEngineFromEpeOam2Info_m epe_oam2_info;
    DbgEpeOamInfo_m dbg_epe_oam_info;
    uint8 key_type[3] = {0};
    uint8 hash_valid[3] = {0};
    uint8 confict[3] = {0};
    uint32 key_index[3] = {0};
    uint8 hash_resultValid[3] = {0};

    sal_memset(&epe_oam0_info, 0, sizeof(epe_oam0_info));
    cmd = DRV_IOR(DbgOamHashEngineFromEpeOam0Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &epe_oam0_info));
    sal_memset(&epe_oam1_info, 0, sizeof(epe_oam1_info));
    cmd = DRV_IOR(DbgOamHashEngineFromEpeOam1Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &epe_oam1_info));
    sal_memset(&epe_oam2_info, 0, sizeof(epe_oam2_info));
    cmd = DRV_IOR(DbgOamHashEngineFromEpeOam2Info_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &epe_oam2_info));
    sal_memset(&dbg_epe_oam_info, 0, sizeof(dbg_epe_oam_info));
    cmd = DRV_IOR(DbgEpeOamInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &dbg_epe_oam_info));

    if (!GetDbgEpeOamInfo(V, valid_f, &dbg_epe_oam_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
    hash_resultValid[0] = GetDbgOamHashEngineFromEpeOam0Info(V, resultValid_f, &epe_oam0_info);
    confict[0] = GetDbgOamHashEngineFromEpeOam0Info(V, hashConflict_f, &epe_oam0_info);
    key_index[0] = GetDbgOamHashEngineFromEpeOam0Info(V, keyIndex_f, &epe_oam0_info);
    hash_valid[0] = GetDbgOamHashEngineFromEpeOam0Info(V, valid_f, &epe_oam0_info);

    hash_resultValid[1] = GetDbgOamHashEngineFromEpeOam1Info(V, resultValid_f, &epe_oam1_info);
    confict[1] = GetDbgOamHashEngineFromEpeOam1Info(V, hashConflict_f, &epe_oam1_info);
    key_index[1] = GetDbgOamHashEngineFromEpeOam1Info(V, keyIndex_f, &epe_oam1_info);
    hash_valid[1] = GetDbgOamHashEngineFromEpeOam1Info(V, valid_f, &epe_oam1_info);

    hash_resultValid[2] = GetDbgOamHashEngineFromEpeOam2Info(V, resultValid_f, &epe_oam2_info);
    confict[2] = GetDbgOamHashEngineFromEpeOam2Info(V, hashConflict_f, &epe_oam2_info);
    key_index[2] = GetDbgOamHashEngineFromEpeOam2Info(V, keyIndex_f, &epe_oam2_info);
    hash_valid[2] = GetDbgOamHashEngineFromEpeOam2Info(V, valid_f, &epe_oam2_info);

    key_type[0] = GetDbgOamHashEngineFromEpeOam0Info(V, oamKeyType_f, &epe_oam0_info);
    key_type[1] = GetDbgOamHashEngineFromEpeOam1Info(V, oamKeyType_f, &epe_oam1_info);
    key_type[2] = GetDbgOamHashEngineFromEpeOam2Info(V, oamKeyType_f, &epe_oam2_info);

    if (key_type[0] || key_type[1] || key_type[2])
    {
        char str[64] = {0};
        for (idx = 0; idx < 3; idx++)
        {
            if (!key_type[idx] || !hash_valid[idx])
            {
                continue;
            }
            /*OAMHASHTYPE_ETH = 0x1*/
            value = key_type[idx] - 0x1;
            sal_sprintf(str, "hash-%d", idx);
            DIAG_INFO_CHAR(pos, str,  STR_ARRAY(lookup_result,value))
            if (confict[idx])
            {
                DIAG_INFO_CHAR(pos, "lookup-result", DIAG_LOOKUP_CONFLICT)
                DIAG_INFO_CHAR(pos, "key-name", STR_ARRAY(key_name,value))
                DIAG_INFO_UINT32(pos, "key-index", key_index[idx])
            }
            else if (hash_resultValid[idx])
            {
                DIAG_INFO_CHAR(pos, "lookup-result", DIAG_LOOKUP_HIT)
                DIAG_INFO_CHAR(pos, "key-name", STR_ARRAY(key_name,value))
                DIAG_INFO_UINT32(pos, "key-index", key_index[idx])
            }
            else
            {
                DIAG_INFO_CHAR(pos, "lookup-result", DIAG_LOOKUP_HIT_NONE)
            }
        }
    }

    if (hash_resultValid[0] || hash_resultValid[1] || hash_resultValid[2])
    {
        value = GetDbgEpeOamInfo(V, oamDestChipId_f, &dbg_epe_oam_info);
        if (GetDbgEpeOamInfo(V, mepEn_f, &dbg_epe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "MEP", "HIT")
            DIAG_INFO_UINT32(pos, "master-chip-id", value)
            DIAG_INFO_UINT32(pos, "mep-index", GetDbgEpeOamInfo(V, mepIndex_f, &dbg_epe_oam_info))
        }
        if (GetDbgEpeOamInfo(V, mipEn_f, &dbg_epe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "MIP", "HIT")
            DIAG_INFO_UINT32(pos, "master-chip-id", value)
        }
        value = GetDbgEpeOamInfo(V, rxOamTypeNew_f, &dbg_epe_oam_info);
        if (value)
        {
            /*RXOAMTYPE_TRILLBFD = 0xc*/
            char* oam_type[] =
            {
                "NONE", "ETHER OAM", "IP BFD", "RESERVED1", "RESERVED2",
                "RESERVED3", "MPLS OAM", "MPLS BFD", "ACH OAM", "NONE","TRILL BFD","TWAMP","FLEX PM TEST"
            };
            DIAG_INFO_CHAR(pos, "oam-type", STR_ARRAY(oam_type,value))
        }
        if (GetDbgEpeOamInfo(V, mplsLmValid_f, &dbg_epe_oam_info) || GetDbgEpeOamInfo(V, etherLmValid_f, &dbg_epe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "action", "read-LM")
            DIAG_INFO_CHAR(pos, "table-name", "DsOamEpeLmStats")
            DIAG_INFO_UINT32(pos, "table-index", GetDbgEpeOamInfo(V, lmStatsIndex_f, &dbg_epe_oam_info))
        }
        if (GetDbgEpeOamInfo(V, lmStatsEn0_f, &dbg_epe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "action", "write-LM")
            DIAG_INFO_CHAR(pos, "table-name", "DsOamEpeLmStats")
            DIAG_INFO_UINT32(pos, "table-index", GetDbgEpeOamInfo(V, lmStatsPtr0_f, &dbg_epe_oam_info))
        }
        if (GetDbgEpeOamInfo(V, lmStatsEn1_f, &dbg_epe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "action", "write-LM")
            DIAG_INFO_CHAR(pos, "table-name", "DsOamEpeLmStats")
            DIAG_INFO_UINT32(pos, "table-index", GetDbgEpeOamInfo(V, lmStatsPtr1_f, &dbg_epe_oam_info))
        }
        if (GetDbgEpeOamInfo(V, lmStatsEn2_f, &dbg_epe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "action", "write-LM")
            DIAG_INFO_CHAR(pos, "table-name", "DsOamEpeLmStats")
            DIAG_INFO_UINT32(pos, "table-index", GetDbgEpeOamInfo(V, lmStatsPtr2_f, &dbg_epe_oam_info))
        }
        if (GetDbgEpeOamInfo(V, oamPrioValid_f, &dbg_epe_oam_info))
        {
            DIAG_INFO_UINT32(pos, "prio", GetDbgEpeOamInfo(V, oamPrio_f, &dbg_epe_oam_info))
        }
        DIAG_INFO_CHAR(pos, "color",STR_ARRAY(sys_diag_color,GetDbgEpeOamInfo(V, oamColor_f, &dbg_epe_oam_info)))
        if (GetDbgEpeOamInfo(V, oamCancelEditing_f, &dbg_epe_oam_info))
        {
            DIAG_INFO_CHAR(pos, "cancel-edit", DIAG_YES)
        }
    }

    cmd = DRV_IOR(DbgEpeHdrEditInfo_t, DbgEpeHdrEditInfo_valid_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
    cmd = DRV_IOR(DbgEpeHdrEditInfo_t, DbgEpeHdrEditInfo_shareType_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &hdr_shareType));
    if ((value) && (4 == hdr_shareType))/*SHARETYPE_OAM = 4*/
    {
        DIAG_INFO_CHAR(pos, "destination", "OAM")
        CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_oam_rx_info(lchip, p_rslt));
    }

    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_epe_pkt_rw_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    uint32 cmd = 0;
    DbgEpePktRwInfo_m pkt_rw_info;
    cmd = DRV_IOR(DbgEpePktRwInfo_t, DRV_ENTRY_FLAG);
    DRV_IOCTL(lchip, 0, cmd, &pkt_rw_info);
    if (GetDbgEpePktRwInfo(V, valid_f, &pkt_rw_info) && GetDbgEpePktRwInfo(V, isTransitNode_f, &pkt_rw_info))
    {
        p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
        DIAG_INFO_NONE(pos, "Packet Rewrite")
        DIAG_INFO_CHAR(pos, "is-attach", GetDbgEpePktRwInfo(V, isAttach_f, &pkt_rw_info)? DIAG_YES: DIAG_NO)
        DIAG_INFO_UINT32(pos, "sec-tag-offset", GetDbgEpePktRwInfo(V, secTagOffset_f, &pkt_rw_info))
        DIAG_INFO_UINT32(pos, "old-l3checksum", GetDbgEpePktRwInfo(V, oldL3Checksum_f, &pkt_rw_info))
        DIAG_INFO_UINT32(pos, "new-l3checksum", GetDbgEpePktRwInfo(V, newL3Checksum_f, &pkt_rw_info))
        if (GetDbgEpePktRwInfo(V, l4ChecksumValid_f, &pkt_rw_info))
        {
            DIAG_INFO_UINT32(pos, "old-l4checksum", GetDbgEpePktRwInfo(V, oldL4Checksum_f, &pkt_rw_info))
            DIAG_INFO_UINT32(pos, "new-l4checksum", GetDbgEpePktRwInfo(V, newL4Checksum_f, &pkt_rw_info))
        }
    }
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_epe_dot1ae_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint64 val_u64 = 0;
    uint32 value[2] = {0};
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    uint8 index = 0;
    DbgMacsecTxInfo_m dbg_macsec_info;

    /*macsec-tx process*/
    for (index = 0; index < MCHIP_CAP(SYS_CAP_DP_MAX_NUM); index++)/* DP0 + DP1*/
    {
        sal_memset(&dbg_macsec_info, 0, sizeof(DbgMacsecTxInfo_m));
        cmd = DRV_IOR(DbgMacsecTxInfo_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, index, cmd, &dbg_macsec_info));

        if ((GetDbgMacsecTxInfo(V, macsecEnable_f, &dbg_macsec_info)) && (GetDbgMacsecTxInfo(V, valid_f, &dbg_macsec_info)))
        {
            p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
            DIAG_INFO_NONE(pos, "Dot1ae Tx")
            DIAG_INFO_UINT32(pos, "macsec-channel", GetDbgMacsecTxInfo(V, channelId_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "bypass-macsec-proc", GetDbgMacsecTxInfo(V, bypassMacsecProc_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "macsec-enable", GetDbgMacsecTxInfo(V, macsecEnable_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "controlled-port-enable", GetDbgMacsecTxInfo(V, controlledPortEnabled_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "protect-frames", GetDbgMacsecTxInfo(V, protectFrames_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "macsec-type", GetDbgMacsecTxInfo(V, macsecType_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "transmit-said", GetDbgMacsecTxInfo(V, transmitSaId_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "sa-in-use", GetDbgMacsecTxInfo(V, saInUse_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "macsec-short-length", GetDbgMacsecTxInfo(V, macsecShortLength_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "is-advanced-macsec", GetDbgMacsecTxInfo(V, isAdvancedMacsec_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "is-cloudsec", GetDbgMacsecTxInfo(V, isCloudSec_f, &dbg_macsec_info))
            GetDbgMacsecTxInfo(A, macsecPn_f, &dbg_macsec_info, value);
            val_u64 = value[1];
            val_u64 = (val_u64 << 32) | value[0];
            DIAG_INFO_UINT64(pos, "macsec-pn", val_u64)

            DIAG_INFO_UINT32(pos, "macsec-sop-discard", GetDbgMacsecTxInfo(V, macsecSopDiscard_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "macsec-discard-type", GetDbgMacsecTxInfo(V, macsecDiscardType_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "secY-stats", GetDbgMacsecTxInfo(V, secYStats_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "secY-pkt-stats-type", GetDbgMacsecTxInfo(V, secYPktStatsType_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "sc-stats", GetDbgMacsecTxInfo(V, scStats_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "sc-pkt-stats-type", GetDbgMacsecTxInfo(V, scPktStatsType_f, &dbg_macsec_info))
            DIAG_INFO_UINT32(pos, "secY-byte-stats", GetDbgMacsecTxInfo(V, secYByteStats_f, &dbg_macsec_info))
        }
    }
    return CTC_E_NONE;
}
STATIC int32
_sys_tmm_diag_pkt_trace_get_epe_edit_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint8  l3edit_type = 0;
    //uint8  l2edit_type = 0;
    uint8  nhp_middleEditPtrEn = 0;
    uint8  next_edit_valid = 0;
    uint8  vlan_edit_valid = 0;
    uint8  l2edit_is6w = 0;
    uint8  outer_edit_ptr_x_valid = 0;
    uint32 cmd = 0;
    uint32 value = 0;
    uint32 value1 = 0;
    uint32 label = 0;
    uint32 edit_valid = 0;
    uint32 nhp_nhpIs8w = 0;
    uint32 nhpShareType = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    //uint8  is_mac_swap = 0, is_eth_edit;
    uint32 dsNextHopInternalBase = 0;
    uint32 nhpOuterEditPtrType = 0;
    uint32 flex_edit_ptr = 0;
    uint32 snat_edit_ptr = 0;
    uint32 flex_edit_base = 0;
    hw_mac_addr_t hw_mac = {0};
    char *sys_diag_vlan_action[] = {"None", "Add", "Delete", "Replace"};
    char* l3_edit[] =
    {
        "NONE",
        "ADDIP4",
        "ADDIP44X",
        "ADDIP6",
        "MPLS1X",
        "MPLS2X",
        "MPLS4X",
        "ADDRAW",
        "RWIP41X",
        "RWIP4",
        "RWIP6",
        "RWFLEX",
        "INSFLEX",
        "DELMPLS",
        "DELFLEX",
        "LOOPBACK",
        "ADDTRILL",
        "RWIP68X",
        "ADDIP68X",
        "RWIP62X"
    };
    char* l3_edit_name[] =
    {
        "",
        "DsL3EditAddIp4",
        "DsL3EditAddIp44X",
        "DsL3EditAddIp6",
        "DsL3EditAddMpls1X",
        "DsL3EditAddMpls2X",
        "DsL3EditAddMpls4X",
        "DsL3EditAddRaw",
        "DsL3EditRwIp41X",
        "DsL3EditRwIp4",
        "DsL3EditRwIp6",
        "DsL3EditRwFlex",
        "DsL3EditInsFlex",
        "DsL3EditDelMpls",
        "DsL3EditDelFlex",
        "DsL3EditLoopback",
        "DsL3EditAddTrill",
        "DsL3EditRwIp6Sr",
        "DsL3EditAddIp6Sr",
        "DsL3EditRwIp62X"
    };

    char* l2_edit[] = {
        "NONE",
        "ADDETH1X",
        "ADDETH2X",
        "ADDRAW",
        "AUTOETH1X",
        "AUTOETH2X",
        "","","",
        "RWETH1X",
        "RWETH2X",
        "","","",
        "GEMPORT",
        "LOOPBACK"
    };
    char* l2_edit_name[] = {
        "",
        "DsL2EditAddEth1X",
        "DsL2EditAddEth2X",
        "DsL2EditAddRaw",
        "DsL2EditAutoEth1X",
        "DsL2EditAutoEth2X",
        "","","",
        "DsL2EditRwEth1X",
        "DsL2EditRwEth2X",
        "","","",
        "DsL2EditGemPort",
        "DsL2EditLoopback"
    };

    DsNextHop8W_m nexthop_8w;
    DsNextHop4W_m nexthop_4w;
    DsL2EditAddEth1X_m l2edit_eth3w;
    DsL2Edit6WOuter_m l2edit_6w_outer;
    DsL2EditAddEth2X_m l2edit_add_eth2X;
    DsL3Edit6W3rd_m l3edit_6w3rd;
    DsL3EditAddMpls1X_m l3edit_mpls1X;
    DsL3Edit12W_m l3edit_12w;
    DbgEpeHdrAdjInfo_m hdr_adj_info;
    DbgEpeNextHopInfo_m nexthop_info;
    DbgEpePldProcInfo_m payload_info;
    DbgEpeEgressEditInfo_m egress_edit_info;
    EpeNextHopCtl_m epe_nh_ctl;
    DbgFwdMetFifoInfo1_m met_fifo_info1;

    uint32 next_edit_ptr = 0;
    uint32 next_edit_type = 0;
    uint32 do_l2_edit = 0;
    uint32 l2_edit_ptr = 0;
    uint32 nhp_outerEditPtr = 0;
    uint32 l2_individual_memory = 0;
    uint32 l3edit_l3RewriteType = 0;
    uint32 l2edit_l2RewriteType = 0;
    uint32 edit_outerEditPipe1Exist = 0;
    uint32 edit_nhpOuterEditLocation = 0;
    uint32 outer_edit_ptr_x = 0;
    //uint8  nhp_innerEditPtrOffset = 0;
    void* ds = NULL;

    sal_memset(&nexthop_8w, 0, sizeof(nexthop_8w));
    sal_memset(&nexthop_4w, 0, sizeof(nexthop_4w));
    sal_memset(&l2edit_eth3w, 0, sizeof(l2edit_eth3w));
    sal_memset(&l3edit_mpls1X, 0, sizeof(l3edit_mpls1X));
    sal_memset(&l2edit_6w_outer, 0, sizeof(l2edit_6w_outer));
    sal_memset(&l2edit_add_eth2X, 0, sizeof(l2edit_add_eth2X));
    sal_memset(&l3edit_6w3rd, 0, sizeof(l3edit_6w3rd));

    /*DbgEpeHdrAdjInfo*/
    sal_memset(&hdr_adj_info, 0, sizeof(hdr_adj_info));
    cmd = DRV_IOR(DbgEpeHdrAdjInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &hdr_adj_info));
    if (GetDbgEpeHdrAdjInfo(V, bypassAll_f, &hdr_adj_info) || GetDbgEpeHdrAdjInfo(V, bypassEpe_f, &hdr_adj_info))
    {
        return CTC_E_NONE;
    }
    sal_memset(&nexthop_info, 0, sizeof(nexthop_info));
    cmd = DRV_IOR(DbgEpeNextHopInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &nexthop_info));
    sal_memset(&payload_info, 0, sizeof(payload_info));
    cmd = DRV_IOR(DbgEpePldProcInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &payload_info));
    sal_memset(&egress_edit_info, 0, sizeof(egress_edit_info));
    cmd = DRV_IOR(DbgEpeEgressEditInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &egress_edit_info));

    edit_valid = GetDbgEpeEgressEditInfo(V, valid_f, &egress_edit_info);
    edit_outerEditPipe1Exist = GetDbgEpeEgressEditInfo(V, outerEditPipe1Exist_f, &egress_edit_info);
    edit_nhpOuterEditLocation = GetDbgEpeNextHopInfo(V, nhpOuterEditLocation_f, &nexthop_info);
    nhp_outerEditPtr = GetDbgEpeNextHopInfo(V, nhpOuterEditPtr_f, &nexthop_info);
    //nhp_innerEditPtrOffset = GetDbgEpeNextHopInfo(V, innerEditPtrOffset_f, &nexthop_info);
    l3edit_l3RewriteType = GetDbgEpeEgressEditInfo(V, l3EditType_f, &egress_edit_info);
    l2edit_l2RewriteType = GetDbgEpeEgressEditInfo(V, l2EditType_f, &egress_edit_info);

    if (!edit_valid && !GetDbgEpeNextHopInfo(V, valid_f, &nexthop_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_EPE;

    DIAG_INFO_NONE(pos, "Flex Editing")

    DIAG_INFO_UINT32(pos, "edit-template-id0", GetDbgEpeNextHopInfo(V, flexEditTemplateId0_f, &nexthop_info))
    DIAG_INFO_UINT32(pos, "edit-template-id1", GetDbgEpeNextHopInfo(V, flexEditTemplateId1_f, &nexthop_info))
    DIAG_INFO_UINT32(pos, "edit-template-id2", GetDbgEpeNextHopInfo(V, flexEditTemplateId2_f, &nexthop_info))
    DIAG_INFO_UINT32(pos, "edit-template-id3", GetDbgEpeNextHopInfo(V, flexEditTemplateId3_f, &nexthop_info))

    snat_edit_ptr = GetDbgEpeNextHopInfo(V, snatEditPtr_f, &nexthop_info);
    flex_edit_ptr = GetDbgEpeNextHopInfo(V, flexEditPtr_f, &nexthop_info);
    cmd = DRV_IOR(EpeNextHopCtl_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &epe_nh_ctl));
    if (0 != snat_edit_ptr)
    {
        flex_edit_base = GetEpeNextHopCtl(V, snatEditPtrBase_f, &epe_nh_ctl);
        DIAG_INFO_U32_HEX(pos, "snat-edit-ptr", flex_edit_base + snat_edit_ptr)
        DIAG_INFO_UINT32(pos, "snat-edit-ptr-type", GetEpeNextHopCtl(V, snatEditPtrType_f, &epe_nh_ctl))
    }
    else if (0 != flex_edit_ptr)
    {

        flex_edit_base = GetEpeNextHopCtl(V, flexEditPtrBase_f, &epe_nh_ctl);
        switch(GetEpeNextHopCtl(V, flexEditPtrMode_f, &epe_nh_ctl))
        {
            case 1:
            {
                DIAG_INFO_U32_HEX(pos, "inner-edit-ptr", flex_edit_base + flex_edit_ptr)
                DIAG_INFO_UINT32(pos, "inner-edit-ptr-type", GetEpeNextHopCtl(V, flexEditPtrType_f, &epe_nh_ctl))
            }
            break;
            case 2:
            {
                DIAG_INFO_U32_HEX(pos, "outer-edit-ptr", flex_edit_base + flex_edit_ptr)
                DIAG_INFO_UINT32(pos, "outer-edit-ptr-type", GetEpeNextHopCtl(V, flexEditPtrType_f, &epe_nh_ctl))
            }
            break;
            case 3:
            {
                if (CTC_IS_BIT_SET(flex_edit_ptr, 14))
                {
                    DIAG_INFO_U32_HEX(pos, "outer-edit-ptr", flex_edit_base + (flex_edit_ptr&0x1FFF))
                    DIAG_INFO_UINT32(pos, "outer-edit-ptr-type", CTC_IS_BIT_SET(flex_edit_ptr, 13))
                }
                else
                {
                    DIAG_INFO_U32_HEX(pos, "inner-edit-ptr", flex_edit_base + (flex_edit_ptr&0x1FFF))
                    DIAG_INFO_UINT32(pos, "inner-edit-ptr-type", CTC_IS_BIT_SET(flex_edit_ptr, 13))
                }
            }
            break;
            default:
            break;
        }
    }

    DIAG_INFO_NONE(pos, "Layer3 Packet Editing")

    if (GetDbgEpePldProcInfo(V, valid_f, &payload_info))
    {

        if (GetDbgEpePldProcInfo(V, newTtlValid_f, &payload_info))
        {
            DIAG_INFO_UINT32(pos, "new-ttl", GetDbgEpePldProcInfo(V, newTtl_f, &payload_info))
        }
        if (GetDbgEpePldProcInfo(V, newDscpValid_f, &payload_info))
        {
            DIAG_INFO_UINT32(pos, "new-dscp", GetDbgEpePldProcInfo(V, newDscp_f, &payload_info))
        }
    }

    cmd = DRV_IOR(EpeHdrAdjustCtl_t, EpeHdrAdjustCtl_dsNextHopInternalBase_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &dsNextHopInternalBase));

    nhp_nhpIs8w = GetDbgEpeNextHopInfo(V, nhpIs8w_f, &nexthop_info);
    value = GetDbgEpeHdrAdjInfo(V, nextHopPtr_f, &hdr_adj_info);
    if ((value >> 4) != dsNextHopInternalBase)
    {
        cmd = DRV_IOR(DsNextHop8W_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, (value >> 1) << 1, cmd, &nexthop_8w));

        if (!nhp_nhpIs8w)
        {
            if (CTC_IS_BIT_SET(value, 0))
            {
                sal_memcpy((uint8*)&nexthop_4w, (uint8*)&nexthop_8w + DRV_TABLE_ENTRY_SIZE(lchip, DsNextHop4W_t), DRV_TABLE_ENTRY_SIZE(lchip, DsNextHop4W_t));
            }
            else
            {
                sal_memcpy((uint8*)&nexthop_4w, (uint8*)&nexthop_8w , DRV_TABLE_ENTRY_SIZE(lchip, DsNextHop4W_t));
            }
        }
    }
    else
    {
        cmd = DRV_IOR(EpeNextHopInternal_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, (value & 0xF) >> 1, cmd, &nexthop_8w));
        if (!nhp_nhpIs8w)
        {
            if (CTC_IS_BIT_SET(value & 0xF , 0))
            {
                sal_memcpy((uint8*)&nexthop_4w, (uint8*)&nexthop_8w + DRV_TABLE_ENTRY_SIZE(lchip, DsNextHop4W_t), DRV_TABLE_ENTRY_SIZE(lchip, DsNextHop4W_t));
            }
            else
            {
                sal_memcpy((uint8*)&nexthop_4w, (uint8*)&nexthop_8w , DRV_TABLE_ENTRY_SIZE(lchip, DsNextHop4W_t));
            }
        }
    }

    if (nhp_nhpIs8w)
    {
        nhpShareType = GetDsNextHop8W(V, shareType_f, &nexthop_8w);
    }
    else
    {
        nhpShareType = GetDsNextHop4W(V, shareType_f, &nexthop_4w);
    }

    /*NHPSHARETYPE_L2EDIT_PLUS_L3EDIT_OP = 0*/
    if ((0 == nhpShareType) || (nhp_nhpIs8w))
    {
        if (nhp_nhpIs8w)
        {
            nhpOuterEditPtrType = GetDsNextHop8W(V, outerEditPtrType_f, &nexthop_8w);
        }
        else
        {
            nhpOuterEditPtrType = GetDsNextHop4W(V, outerEditPtrType_f, &nexthop_4w);
        }
        /*inner edit*/
        value = GetDbgEpeNextHopInfo(V, nhpInnerEditPtr_f, &nexthop_info);
        if (edit_valid
            && GetDbgEpeEgressEditInfo(V, innerEditExist_f, &egress_edit_info))
        {
            if (GetDbgEpeEgressEditInfo(V, nhpInnerEditPtrEn_f, &egress_edit_info) &&
                GetDbgEpeEgressEditInfo(V, innerEditPtrType_f, &egress_edit_info))
            {
                DIAG_INFO_CHAR(pos, "inner-l3edit",STR_ARRAY(l3_edit,l3edit_l3RewriteType))
                if (l3edit_l3RewriteType == DRV_ENUM(DRV_L3EDITTYPE_MPLS1X) ||
                    l3edit_l3RewriteType == DRV_ENUM(DRV_L3EDITTYPE_MPLS2X) ||
                    l3edit_l3RewriteType == DRV_ENUM(DRV_L3EDITTYPE_MPLS4X))
                {
                    cmd = DRV_IOR(DsL3EditAddMpls1X_t, DRV_ENTRY_FLAG);
                    CTC_ERROR_RETURN(DRV_IOCTL(lchip, value, cmd, &l3edit_mpls1X));
                    label = GetDsL3EditAddMpls1X(V, label_f, &l3edit_mpls1X);
                    DIAG_INFO_UINT32(pos, "new-label", label)
                }
                DIAG_INFO_UINT32(pos, "edit-table-index", value)
                DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l3_edit_name,l3edit_l3RewriteType))
            }
            else if (GetDbgEpeEgressEditInfo(V, nhpInnerEditPtrEn_f, &egress_edit_info) &&
                     !GetDbgEpeEgressEditInfo(V, innerEditPtrType_f, &egress_edit_info))
            {
                DIAG_INFO_CHAR(pos, "inner-l2edit", STR_ARRAY(l2_edit,l2edit_l2RewriteType))
                DIAG_INFO_UINT32(pos, "edit-table-index", value)
                DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l2_edit_name,l2edit_l2RewriteType))
            }
        }

        nhp_middleEditPtrEn = GetDbgEpeEgressEditInfo(V, nhpMiddleEditPtrEn_f, &egress_edit_info);
        if ((nhp_middleEditPtrEn || GetDbgEpeEgressEditInfo(V, nhpOuterEditPtrEn_f, &egress_edit_info)) && edit_valid)
        {
            /*outer pipeline0*/
            if (edit_outerEditPipe1Exist)
            {
                cmd = DRV_IOR(DsL3Edit12W_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip, (nhp_outerEditPtr >> 2) << 2, cmd, &l3edit_12w));
                l3edit_type = GetDsL3Edit12W(V, l3EditType_f, &egress_edit_info);
                if (GetDbgEpeEgressEditInfo(V, nhpOuterEditPtrEn_f, &egress_edit_info) &&
                    nhpOuterEditPtrType && !edit_nhpOuterEditLocation)  /* share memory */
                {
                    if (!(nhp_outerEditPtr & 0x3) && GetDbgEpeEgressEditInfo(V, innerEditExist_f, &egress_edit_info) &&
                        GetDbgEpeEgressEditInfo(V, innerEditPtrType_f, &egress_edit_info) &&
                        GetDbgEpeEgressEditInfo(V, innerEditType_f, &egress_edit_info) == DIAG_EDITTYPE_TYPE8X) /*srv6*/
                    {
                        DIAG_INFO_CHAR(pos, "outer-srv6-edit", STR_ARRAY(l3_edit,l3edit_l3RewriteType))
                        DIAG_INFO_UINT32(pos, "edit-table-index", nhp_outerEditPtr >> 2)
                        DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l3_edit_name,l3edit_l3RewriteType))
                        if (GetDsL3Edit12W(V, nextEditPtrValid_f, &l3edit_12w))
                        {
                            next_edit_ptr = GetDsL3Edit12W(V, outerEditPtr_f, &l3edit_12w);
                            next_edit_type = GetDsL3Edit12W(V, outerEditPtrType_f, &l3edit_12w);
                            next_edit_valid = 1;
                        }
                        else if (GetDsL3Edit12W(V, outerEditPtr_f, &l3edit_12w))
                        {
                            next_edit_ptr = GetDsL3Edit12W(V, outerEditPtr_f, &l3edit_12w);
                            next_edit_type = 1;
                            next_edit_valid = 1;
                        }
                        else
                        {
                            next_edit_ptr = 0;
                            next_edit_valid = 0;
                        }
                    }
                    else if (!(nhp_outerEditPtr & 0x3) &&
                                (l3edit_type == DIAG_L3EDITTYPE_ADDIP44X    ||
                                 l3edit_type == DIAG_L3EDITTYPE_ADDIP6      ||
                                 l3edit_type == DIAG_L3EDITTYPE_RWIP6       ||
                                 l3edit_type == DIAG_L3EDITTYPE_MPLS4X      ||
                                 l3edit_type == DIAG_L3EDITTYPE_RWFLEX      ||
                                 l3edit_type == DIAG_L3EDITTYPE_INSFLEX     ||
                                 l3edit_type == DIAG_L3EDITTYPE_DELFLEX))
                    {
                        DIAG_INFO_CHAR(pos, "outer-edit", STR_ARRAY(l3_edit,l3edit_l3RewriteType))
                        DIAG_INFO_UINT32(pos, "edit-table-index", nhp_outerEditPtr >> 2)
                        DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l3_edit_name,l3edit_l3RewriteType))
                        if (GetDsL3Edit12W(V, nextEditPtrValid_f, &l3edit_12w))
                        {
                            next_edit_ptr = GetDsL3Edit12W(V, outerEditPtr_f, &l3edit_12w);
                            next_edit_type = GetDsL3Edit12W(V, outerEditPtrType_f, &l3edit_12w);
                            next_edit_valid = 1;
                        }
                        else if (GetDsL3Edit12W(V, outerEditPtr_f, &l3edit_12w))
                        {
                            next_edit_ptr = GetDsL3Edit12W(V, outerEditPtr_f, &l3edit_12w);
                            next_edit_type = 1;
                            next_edit_valid = 1;
                        }
                        else
                        {
                            next_edit_ptr = 0;
                            next_edit_valid = 0;
                        }
                    }
                    else if (CTC_IS_BIT_SET(nhp_outerEditPtr, 0))
                    {
                        DIAG_INFO_CHAR(pos, "outer-edit", STR_ARRAY(l3_edit,l3edit_l3RewriteType))
                        DIAG_INFO_UINT32(pos, "edit-table-index", nhp_outerEditPtr)
                        DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l3_edit_name,l3edit_l3RewriteType))
                        if (!CTC_IS_BIT_SET(nhp_outerEditPtr, 1))
                        {
                            ds = (uint8*)&l3edit_12w + DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit3W_t);
                        }
                        else
                        {
                            ds = (uint8*)&l3edit_12w + 3 * DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit3W_t);
                        }
                        if (l3edit_l3RewriteType == DIAG_L3EDITTYPE_MPLS1X)
                        {
                            DIAG_INFO_UINT32(pos, "new-label", GetDsL3EditAddMpls1X(V, label_f, ds))
                        }
                        if (GetDsL3Edit3W(V, nextEditPtrValid_f, ds))
                        {
                            next_edit_ptr = GetDsL3Edit3W(V, outerEditPtr_f, ds);
                            next_edit_type = GetDsL3Edit3W(V, outerEditPtrType_f, ds);
                            next_edit_valid = 1;
                        }
                        else if (GetDsL3Edit3W(V, outerEditPtr_f, ds))
                        {
                            next_edit_ptr = GetDsL3Edit3W(V, outerEditPtr_f, ds);
                            next_edit_type = 1;
                            next_edit_valid = 1;
                        }
                        else
                        {
                            next_edit_ptr = 0;
                            next_edit_valid = 0;
                        }
                    }
                    else
                    {
                        DIAG_INFO_CHAR(pos, "outer-edit", STR_ARRAY(l3_edit,l3edit_l3RewriteType))
                        if (!CTC_IS_BIT_SET(nhp_outerEditPtr, 1))
                        {
                            ds = (uint8*)&l3edit_12w;
                        }
                        else
                        {
                            ds = (uint8*)&l3edit_12w + DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit6W_t);
                        }
                        if (l3edit_l3RewriteType == DIAG_L3EDITTYPE_MPLS1X)
                        {
                            DIAG_INFO_UINT32(pos, "new-label", GetDsL3EditAddMpls1X(V, label_f, ds))
                        }
                        DIAG_INFO_UINT32(pos, "edit-table-index", nhp_outerEditPtr)
                        DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l3_edit_name,l3edit_l3RewriteType))
                        l3edit_type = GetDsL3Edit6W(V, l3EditType_f, ds);
                        if (l3edit_type == DIAG_L3EDITTYPE_ADDIP4   ||
                            l3edit_type == DIAG_L3EDITTYPE_MPLS2X   ||
                            l3edit_type == DIAG_L3EDITTYPE_ADDRAW   ||
                            l3edit_type == DIAG_L3EDITTYPE_RWIP4)
                        {
                            if (GetDsL3Edit6W(V, nextEditPtrValid_f, ds))
                            {
                                next_edit_ptr = GetDsL3Edit6W(V, outerEditPtr_f, ds);
                                next_edit_type = GetDsL3Edit6W(V, outerEditPtrType_f, ds);
                                next_edit_valid = 1;
                            }
                            else if (GetDsL3Edit6W(V, outerEditPtr_f, ds))
                            {
                                next_edit_ptr = GetDsL3Edit6W(V, outerEditPtr_f, ds);
                                next_edit_type = 1;
                                next_edit_valid = 1;
                            }
                            else
                            {
                                next_edit_ptr = 0;
                                next_edit_valid = 0;
                            }
                        }
                        else if (l3edit_type == DIAG_L3EDITTYPE_RWIP62X)    //construct 12w to process
                        {
                            ;
                        }
                        else
                        {
                            if (GetDsL3Edit3W(V, nextEditPtrValid_f, ds))
                            {
                                next_edit_ptr = GetDsL3Edit3W(V, outerEditPtr_f, ds);
                                next_edit_type = GetDsL3Edit3W(V, outerEditPtrType_f, ds);
                                next_edit_valid = 1;
                            }
                            else if (GetDsL3Edit3W(V, outerEditPtr_f, ds))
                            {
                                next_edit_ptr = GetDsL3Edit3W(V, outerEditPtr_f, ds);
                                next_edit_type = 1;
                                next_edit_valid = 1;
                            }
                            else
                            {
                                next_edit_ptr = 0;
                                next_edit_valid = 0;
                            }
                        }
                    }
                }
                else if (GetDbgEpeEgressEditInfo(V, nhpOuterEditPtrEn_f, &egress_edit_info) &&
                         nhpOuterEditPtrType && edit_nhpOuterEditLocation)
                {
                    next_edit_ptr = nhp_outerEditPtr;
                    next_edit_type = nhpOuterEditPtrType;
                    next_edit_valid = 1;
                }
                else if (GetDbgEpeEgressEditInfo(V, nhpOuterEditPtrEn_f, &egress_edit_info) &&
                         !nhpOuterEditPtrType && !edit_nhpOuterEditLocation)    /*share memory*/
                {
                    do_l2_edit = 1;
                    l2_edit_ptr = nhp_outerEditPtr;
                    l2_individual_memory = 0;
                    if (CTC_IS_BIT_SET(nhp_outerEditPtr, 0))
                    {
                        if (!CTC_IS_BIT_SET(nhp_outerEditPtr, 1))
                        {
                            ds = (uint8*)&l3edit_12w + DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit3W_t);
                        }
                        else
                        {
                            ds = (uint8*)&l3edit_12w + 3 * DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit3W_t);
                        }
                        l2edit_l2RewriteType = GetDsL2Edit3W(V, l2EditType_f, ds);
                    }
                    else if (!CTC_IS_BIT_SET(nhp_outerEditPtr, 1))
                    {
                        ds = (uint8*)&l3edit_12w;
                        l2edit_l2RewriteType = GetDsL2Edit6W(V, l2EditType_f, ds);
                    }
                    else
                    {
                        ds = (uint8*)&l3edit_12w + 2 * DRV_TABLE_ENTRY_SIZE(lchip, DsL2Edit3W_t);
                        l2edit_l2RewriteType = GetDsL2Edit6W(V, l2EditType_f, ds);
                    }
                }
                else if (GetDbgEpeEgressEditInfo(V, nhpOuterEditPtrEn_f, &egress_edit_info) &&
                         !nhpOuterEditPtrType && edit_nhpOuterEditLocation)
                {
                    next_edit_ptr = nhp_outerEditPtr;
                    next_edit_type = nhpOuterEditPtrType;
                    next_edit_valid = 1;
                }
                if (nhp_middleEditPtrEn)
                {
                    if (next_edit_valid && !next_edit_type)
                    {
                        outer_edit_ptr_x_valid = 1;
                        outer_edit_ptr_x = next_edit_ptr;
                    }
                    next_edit_ptr = GetDbgEpeEgressEditInfo(V, nhpMiddleEditPtr_f, &egress_edit_info);
                    next_edit_type = 1;
                    next_edit_valid = 1;
                }
            }
            /*outer pipeline1*/
            if (GetDbgEpeEgressEditInfo(V, outerEditPipe2Exist_f, &egress_edit_info) && next_edit_valid)
            {
                cmd = DRV_IOR(DsL3Edit6W3rd_t, DRV_ENTRY_FLAG);
                DRV_IOCTL(lchip, next_edit_ptr >> 1, cmd, &l3edit_6w3rd);
                DIAG_INFO_CHAR(pos, "outer-l3edit", STR_ARRAY(l3_edit,GetDsL3Edit6W3rd(V, l3EditType_f, &l3edit_6w3rd)))
                DIAG_INFO_U32_HEX(pos, "edit-table-index", next_edit_ptr)
                DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l3_edit_name,GetDsL3Edit6W3rd(V, l3EditType_f, &l3edit_6w3rd)))
                if (!GetDbgEpeEgressEditInfo(V, outerEditPipe2ForL2Edit_f, &egress_edit_info))
                {
                    //next_edit_ptr = next_edit_ptr + (nhp_middleEditPtrEn? );spmeProtectEn useless

                    if (!CTC_IS_BIT_SET(next_edit_ptr, 0) && GetDsL3Edit6W3rd(V, l3EditType_f, &l3edit_6w3rd) == DIAG_L3EDITTYPE_MPLS2X)
                    {
                        if (!GetDsL3Edit6W3rd(V, nextEditPtrValid_f, &l3edit_6w3rd))
                        {
                            next_edit_ptr = 0;
                            next_edit_valid = 0;
                        }
                        else
                        {
                            next_edit_ptr = GetDsL3Edit6W3rd(V, outerEditPtr_f, &l3edit_6w3rd);
                            next_edit_type = GetDsL3Edit6W3rd(V, outerEditPtrType_f, &l3edit_6w3rd);
                            next_edit_valid = 1;
                        }
                    }
                    else
                    {
                        if (!CTC_IS_BIT_SET(next_edit_ptr, 0))
                        {
                            ds = (uint8*)&l3edit_6w3rd;
                        }
                        else
                        {
                            ds = (uint8*)&l3edit_6w3rd + DRV_TABLE_ENTRY_SIZE(lchip, DsL3Edit3W_t);
                        }
                        if (GetDsL3Edit3W3rd(V, nextEditPtrValid_f, ds))
                        {
                            next_edit_ptr = 0;
                            next_edit_valid = 0;
                        }
                        else
                        {
                            next_edit_ptr = GetDsL3Edit3W3rd(V, outerEditPtr_f, ds);
                            next_edit_type = GetDsL3Edit3W3rd(V, outerEditPtrType_f, ds);
                            next_edit_valid = 1;
                        }
                    }
                }
                else
                {
                    cmd = DRV_IOR(DsL3Edit6W3rd_t, DRV_ENTRY_FLAG);
                    DRV_IOCTL(lchip, next_edit_ptr >> 1, cmd, &l3edit_6w3rd);
                    next_edit_valid = 0;
                    do_l2_edit = 1;
                    l2_edit_ptr = next_edit_ptr;
                    l2_individual_memory = 1;
                    ds = &l3edit_6w3rd;
                }
            }
            if (nhp_middleEditPtrEn && outer_edit_ptr_x_valid)
            {
                next_edit_ptr = outer_edit_ptr_x;
                next_edit_type = 0;
                next_edit_valid = 1;
            }

            /*outer pipeline2*/
            if (!next_edit_type && next_edit_valid)
            {
                do_l2_edit = 1;
                l2_edit_ptr = next_edit_ptr;
                l2_individual_memory = 1;
                l2edit_is6w = (DIAG_EDITTYPE_TYPE2X == GetDbgEpeEgressEditInfo(V, outerEditPipe3Type_f, &egress_edit_info));
            }
        }
    }
    else if (2 == nhpShareType)/*NHPSHARETYPE_L2EDIT_PLUS_STAG_OP = 2*/
    {
        /*inner edit*/
        value = GetDbgEpeNextHopInfo(V, nhpInnerEditPtr_f, &nexthop_info);
        if (edit_valid
            && GetDbgEpeEgressEditInfo(V, innerEditExist_f, &egress_edit_info))
        {
            if (GetDbgEpeEgressEditInfo(V, nhpInnerEditPtrEn_f, &egress_edit_info) &&
                GetDbgEpeEgressEditInfo(V, innerEditPtrType_f, &egress_edit_info))
            {
                DIAG_INFO_CHAR(pos, "inner-l3edit",STR_ARRAY(l3_edit,l3edit_l3RewriteType))
                if (l3edit_l3RewriteType == DRV_ENUM(DRV_L3EDITTYPE_MPLS1X) ||
                    l3edit_l3RewriteType == DRV_ENUM(DRV_L3EDITTYPE_MPLS2X) ||
                    l3edit_l3RewriteType == DRV_ENUM(DRV_L3EDITTYPE_MPLS4X))
                {
                    cmd = DRV_IOR(DsL3EditAddMpls1X_t, DRV_ENTRY_FLAG);
                    CTC_ERROR_RETURN(DRV_IOCTL(lchip, value, cmd, &l3edit_mpls1X));
                    label = GetDsL3EditAddMpls1X(V, label_f, &l3edit_mpls1X);
                    DIAG_INFO_UINT32(pos, "new-label", label)
                }
                DIAG_INFO_UINT32(pos, "edit-table-index", value)
                DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l3_edit_name,l3edit_l3RewriteType))
            }
            else if (GetDbgEpeEgressEditInfo(V, nhpInnerEditPtrEn_f, &egress_edit_info) &&
                     !GetDbgEpeEgressEditInfo(V, innerEditPtrType_f, &egress_edit_info))
            {
                DIAG_INFO_CHAR(pos, "inner-l2edit", STR_ARRAY(l2_edit,l2edit_l2RewriteType))
                DIAG_INFO_UINT32(pos, "edit-table-index", value)
                DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l2_edit_name,l2edit_l2RewriteType))
            }
        }

        if (l2edit_l2RewriteType)/* l2edit */
        {
            do_l2_edit = 1;
            l2_edit_ptr = nhp_outerEditPtr;
            l2_individual_memory = edit_nhpOuterEditLocation? 1 : 0;
        }
    }

    DIAG_INFO_NONE(pos, "Layer2 Packet Editing")
    if (GetDbgEpePldProcInfo(V, valid_f, &payload_info))
    {
        value = GetDbgEpePldProcInfo(V, svlanTagOperation_f, &payload_info);
        value1 = GetDbgEpePldProcInfo(V, cvlanTagOperation_f, &payload_info);
        vlan_edit_valid =   (value == DIAG_VLAN_ACTION_DELETE)  && GetDbgEpePldProcInfo(V, outputSvlanIdValid_f, &payload_info)     &&
                            (value1 == DIAG_VLAN_ACTION_ADD)    && !GetDbgEpePldProcInfo(V, outputCvlanIdValid_f, &payload_info);
        value = vlan_edit_valid? DIAG_VLAN_ACTION_ADD : value;
        if (value || value1)
        {
            if (value)
            {
                DIAG_INFO_CHAR(pos, "svlan-edit", STR_ARRAY(sys_diag_vlan_action,value))
                if ((DIAG_VLAN_ACTION_MODIFY == value) || (DIAG_VLAN_ACTION_ADD== value))
                {
                    value = GetDbgEpePldProcInfo(V, l2NewSvlanTag_f, &payload_info);
                    DIAG_INFO_UINT32(pos, "new-cos", (value >> 13) & 0x7)
                    DIAG_INFO_UINT32(pos, "new-cfi", (value >> 12) & 0x1)
                    DIAG_INFO_UINT32(pos, "new-vlan-id", value & 0xFFF)
                }
            }
            if (value1)
            {
                DIAG_INFO_CHAR(pos, "cvlan-edit", STR_ARRAY(sys_diag_vlan_action,value1))
                if ((DIAG_VLAN_ACTION_MODIFY == value1) || (DIAG_VLAN_ACTION_ADD== value1))
                {
                    value1 = GetDbgEpePldProcInfo(V, l2NewCvlanTag_f, &payload_info);
                    DIAG_INFO_UINT32(pos, "new-cos", (value1 >> 13) & 0x7)
                    DIAG_INFO_UINT32(pos, "new-cfi", (value1 >> 12) & 0x1)
                    DIAG_INFO_UINT32(pos, "new-vlan-id", value1 & 0xFFF)
                }
            }
        }
    }
    cmd = DRV_IOR(DbgFwdMetFifoInfo1_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &met_fifo_info1));

    if ((DIAG_PLD_OP_ROUTE_COMPACT == GetDbgEpeNextHopInfo(V, payloadOperation_f, &nexthop_info) ||
        (DIAG_PLD_OP_NONE == GetDbgEpeNextHopInfo(V, payloadOperation_f, &nexthop_info) &&
         GetDbgEpeNextHopInfo(V, routeNoL2Edit_f, &nexthop_info))) && GetDbgFwdMetFifoInfo1(V, valid_f, &met_fifo_info1))
    {
        uint32 dest_map = 0;
        dest_map = GetDbgFwdMetFifoInfo1(V, destMap_f, &met_fifo_info1);

        if (!CTC_IS_BIT_SET(dest_map,18))
        {
            GetDsNextHop4W(A, macDa_f, &nexthop_4w, hw_mac);
            DIAG_INFO_CHAR(pos, "mac-edit", "ENABLE")
            DIAG_INFO_MAC(pos, "new-macda", hw_mac)
        }
    }
    /*NHPSHARETYPE_L2EDIT_PLUS_L3EDIT_OP=0*/
    if ((0 == nhpShareType) || (nhp_nhpIs8w))
    {
        /*inner edit*/
        value = GetDbgEpeNextHopInfo(V, nhpInnerEditPtr_f, &nexthop_info);
        if (edit_valid
            && GetDbgEpeEgressEditInfo(V, innerEditExist_f, &egress_edit_info)
            && !GetDbgEpeEgressEditInfo(V, innerEditPtrType_f, &egress_edit_info))/* inner for l2edit */
        {
            if (value)
            {
                value1 = GetDbgEpeEgressEditInfo(V, innerL2EditType_f, &egress_edit_info);
                DIAG_INFO_CHAR(pos, "inner-mac-edit", STR_ARRAY(l2_edit,value1))
                DIAG_INFO_UINT32(pos, "edit-table-index", value)
                DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l2_edit_name,value1))
            }
            else if (l2edit_l2RewriteType)
            {
                do_l2_edit = 1;
                l2_edit_ptr = value;
                l2_individual_memory = 0;
            }
        }
    }
    if (do_l2_edit)
    {
        DIAG_INFO_CHAR(pos, "l2edit", STR_ARRAY(l2_edit,l2edit_l2RewriteType))
        DIAG_INFO_UINT32(pos, "edit-table-index", l2_edit_ptr)
        if (l2edit_is6w && l2_individual_memory)
        {
            DIAG_INFO_CHAR(pos, "edit-table-name", "DsL2Edit6WOuter")
        }
        else if (l2_individual_memory)
        {
            DIAG_INFO_CHAR(pos, "edit-table-name", "DsL2Edit3WOuter")
            cmd = DRV_IOR(DsL2Edit6WOuter_t, DRV_ENTRY_FLAG);
            DRV_IOCTL(lchip, l2_edit_ptr >> 1, cmd, &l2edit_6w_outer);
            if (CTC_IS_BIT_SET(l2_edit_ptr, 0))
            {
                ds = (uint8*)&l2edit_6w_outer + DRV_TABLE_ENTRY_SIZE(lchip, DsL2Edit3WOuter_t);
            }
            else
            {
                ds = (uint8*)&l2edit_6w_outer;
            }
            if (GetDsL2EditAddEth1X(V, macDaEn_f, ds))
            {
                GetDsL2EditAddEth1X(A, macDa_f, ds, hw_mac);
                DIAG_INFO_MAC(pos, "New-Mac", hw_mac)
            }
        }
        else
        {
            DIAG_INFO_CHAR(pos, "edit-table-name", STR_ARRAY(l2_edit_name,l2edit_l2RewriteType))
            cmd = DRV_IOR(DsL2EditRwEth2X_t, DRV_ENTRY_FLAG);
            DRV_IOCTL(lchip, l2_edit_ptr, cmd, &l2edit_6w_outer);
            if ((l2edit_l2RewriteType == DIAG_L2EDIT_TYPE_RWETH2X) &&
                (GetDsL2EditRwEth2X(V, macSaRewriteEn_f, &l2edit_6w_outer) && GetDsL2EditRwEth2X(V, macSaCopyDst_f, &l2edit_6w_outer) &&
                 GetDsL2EditRwEth2X(V, macDaRewriteEn_f, &l2edit_6w_outer) && GetDsL2EditRwEth2X(V, macDaCopySrc_f, &l2edit_6w_outer)))
            {
                DIAG_INFO_CHAR(pos, "Mac-Swap", DIAG_ENABLE);
            }
        }
    }

    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_epe_hdr_edit_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    DbgEpeHdrEditInfo_m edit_info;
    MsEpeHdrEditToQMgr_m epe2qmgr_info;
    char* str_type[] = {"IPv4", "IPv6", "MPLS", "TRILL"};
    char* sys_diag_int_op[] = {"", "SOURCE", "TRANSIT", "SINK"};
    char *sys_diag_vlan_action[] = {"None", "Add", "Delete", "Replace"};

    sal_memset(&edit_info, 0, sizeof(DbgEpeHdrEditInfo_m));
    cmd = DRV_IOR(DbgEpeHdrEditInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &edit_info));
    if (!GetDbgEpeHdrEditInfo(V, valid_f, &edit_info))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_EPE;
    DIAG_INFO_NONE(pos, "EPE Header Editing")

    value = GetDbgEpeHdrEditInfo(V, cfHeaderLen_f, &edit_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "stacking-header-length", value)
    }
    value = GetDbgEpeHdrEditInfo(V, l2NewHeaderLen_f, &edit_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "new-l2-header-length", value)
    }
    value = GetDbgEpeHdrEditInfo(V, l2NewHeaderOuterLen_f, &edit_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "new-l2-outer-header-length", value)
    }
    value = GetDbgEpeHdrEditInfo(V, l3NewHeaderLen_f, &edit_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "new-l3-header-length", value)
    }
    value = GetDbgEpeHdrEditInfo(V, l3NewHeaderOuterLen_f, &edit_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "new-l3-outer-header-length", value)
    }

    DIAG_INFO_UINT32(pos, "local-src-port", GetDbgEpeHdrEditInfo(V, srcLocalPhyPort_f, &edit_info))
    DIAG_INFO_UINT32(pos, "local-dst-port", GetDbgEpeHdrEditInfo(V, destLocalPhyPort_f, &edit_info))

    if (GetDbgEpeHdrEditInfo(V, loopbackEn_f, &edit_info))
    {
        DIAG_INFO_CHAR(pos, "loopback", "ENABLE")
    }
    if (GetDbgEpeHdrEditInfo(V, isSpanPkt_f, &edit_info) && GetDbgEpeHdrEditInfo(V, egressExceptionVectorValid_f, &edit_info))
    {
        DIAG_INFO_CHAR(pos, "is-span-packet", "TRUE")
    }
    if (GetDbgEpeHdrEditInfo(V, egressExceptionVectorValid_f, &edit_info))
    {
        DIAG_INFO_U32_HEX(pos, "exception-vector", (GetDbgEpeHdrEditInfo(V, exceptionVector_f, &edit_info)))
    }
    if (GetDbgEpeHdrEditInfo(V, isAdvancedMacsec_f, &edit_info))
    {
        DIAG_INFO_CHAR(pos, "is-adv-mac-sec", "TRUE")
    }
    if (GetDbgEpeHdrEditInfo(V, isCloudSec_f, &edit_info))
    {
        DIAG_INFO_CHAR(pos, "is-cloud-sec", "TRUE")
    }
    if (GetDbgEpeHdrEditInfo(V, newTtlValid_f, &edit_info))
    {
        DIAG_INFO_CHAR(pos, "new-ttl-packet-type", STR_ARRAY(str_type,GetDbgEpeHdrEditInfo(V, newTtlPacketType_f, &edit_info)))
    }

    value = GetDbgEpeHdrEditInfo(V, aclCvlanTagOperation_f, &edit_info) << 16;
    value = value | GetDbgEpeHdrEditInfo(V, aclSvlanTagOperation_f, &edit_info);
    if (value)
    {
        DIAG_INFO_CHAR(pos, "acl-edit-stag", STR_ARRAY(sys_diag_vlan_action,(value & 0xFFFF)))
        DIAG_INFO_CHAR(pos, "acl-edit-ctag", STR_ARRAY(sys_diag_vlan_action,(value >> 16)))
    }

    if (GetDbgEpeHdrEditInfo(V, sourceChannelLinkAggregateEn_f, &edit_info))
    {
        DIAG_INFO_UINT32(pos, "src-chan-agg-id", GetDbgEpeHdrEditInfo(V, sourceChannelLinkAggregate_f, &edit_info))
    }
    if (GetDbgEpeHdrEditInfo(V, destChannelLinkAggregateEn_f, &edit_info))
    {
        DIAG_INFO_UINT32(pos, "dst-chan-agg-id", GetDbgEpeHdrEditInfo(V, destChannelLinkAggregate_f, &edit_info))
    }

    value = GetDbgEpeHdrEditInfo(V, intOpType_f, &edit_info);
    if (value)
    {
        DIAG_INFO_CHAR(pos, "int-op-type", STR_ARRAY(sys_diag_int_op,value))
        DIAG_INFO_U32_HEX(pos, "int-op-ptr", GetDbgEpeHdrEditInfo(V, intOpPtr_f, &edit_info))
    }

    if (GetDbgEpeHdrEditInfo(V, vlanEncodeEn_f, &edit_info) && GetDbgEpeHdrEditInfo(V, voltIdEn_f, &edit_info)) /*Mux vlan*/
    {
        DIAG_INFO_UINT32(pos, "volt-id-en", GetDbgEpeHdrEditInfo(V, vlanEncodeType_f, &edit_info))
    }
    else if (GetDbgEpeHdrEditInfo(V, vlanEncodeEn_f, &edit_info))
    {
        DIAG_INFO_UINT32(pos, "vlan-encode-type", GetDbgEpeHdrEditInfo(V, vlanEncodeType_f, &edit_info)) /*Mux vlan*/
    }
    GetDbgEpeHdrEditInfo(A, msEpeHdrEditToQMgr_f, &edit_info, &epe2qmgr_info);
    DIAG_INFO_UINT32(pos, "to-qmgr-chan-id", GetMsEpeHdrEditToQMgr(V, channelId_f, &epe2qmgr_info))
    DIAG_INFO_UINT32(pos, "to-qmgr-queue-id", GetMsEpeHdrEditToQMgr(V, queueId_f, &epe2qmgr_info))

    /* Drop Process */
    _sys_tmm_diag_pkt_tracce_drop_map(lchip,p_rslt,
                                          GetDbgEpeHdrEditInfo(V, discard_f, &edit_info),
                                          GetDbgEpeHdrEditInfo(V, discardType_f,  &edit_info));
    /* Exception Process */
    _sys_tmm_diag_pkt_tracce_exception_map(lchip,p_rslt,
                                               GetDbgEpeHdrEditInfo(V, exceptionEn_f, &edit_info),
                                               GetDbgEpeHdrEditInfo(V, exceptionIndex_f, &edit_info),
                                               GetDbgEpeHdrEditInfo(V, exceptionSubIndex_f, &edit_info));
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_epe_hmac_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint64 val_64 = 0;
    uint32 array_value[2] = {0};
    uint8 pos = CTC_DIAG_TRACE_POS_EPE;
    DbgHmacInfo_m hmac_info;

    cmd = DRV_IOR(DbgHmacInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &hmac_info));
    if (!GetDbgHmacInfo(V, valid_f, &hmac_info))
    {
        return CTC_E_NONE;
    }
    if (GetDbgHmacInfo(V, checkFail_f, &hmac_info))
    {
        DIAG_INFO_CHAR(pos, "hmac-check-fail", "YES")
    }
    DIAG_INFO_UINT32(pos, "hmac-offset", GetDbgHmacInfo(V, hmacOffset_f, &hmac_info))
    DIAG_INFO_UINT32(pos, "hmac-sha-key-index", GetDbgHmacInfo(V, shaKeyIndex_f, &hmac_info))

    GetDbgHmacInfo(A, calHmac_f, &hmac_info, array_value);
    val_64 = array_value[1];
    val_64 = val_64 << 32 | array_value[0];
    DIAG_INFO_U64_HEX(pos, "cal-hmac", val_64)

    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_tm_bs_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_TM;
    char* str[] = {"UCAST-H", "UCAST-L", "MCAST-H", "MCAST-L"};
    DbgFwdBufStoreInfo_m buf_store_info;

    sal_memset(&buf_store_info, 0, sizeof(buf_store_info));
    cmd = DRV_IOR(DbgFwdBufStoreInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &buf_store_info));

    if (!GetDbgFwdBufStoreInfo(V, valid_f, &buf_store_info))
    {
        return CTC_E_NONE;
    }
    
    p_rslt->position = CTC_DIAG_TRACE_POS_TM;
    DIAG_INFO_NONE(pos, "BufferStore")
    value = GetDbgFwdBufStoreInfo(V, metFifoHighPriority_f, &buf_store_info);
    DIAG_INFO_CHAR(pos, "met-fifo-high-prio", value? DIAG_YES: DIAG_NO)
    value = GetDbgFwdBufStoreInfo(V, metFifoSelect_f, &buf_store_info);
    DIAG_INFO_CHAR(pos, "met-fifo-priority", STR_ARRAY(str,value))
    value = GetDbgFwdBufStoreInfo(V, exceptionVector_f, &buf_store_info);
    if (value & (1 << CTC_DIAG_EXCP_VEC_EXCEPTION))
    {
        DIAG_INFO_U32_HEX(pos, "exception-vector", value)
        p_rslt->dest_type = CTC_DIAG_DEST_CPU;
        p_rslt->excp_vector = value;
        p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_EXCP_VECTOR;
    }
    value = GetDbgFwdBufStoreInfo(V, destChannelIdValid_f, &buf_store_info);
    if (value)
    {
        DIAG_INFO_UINT32(pos, "dest-channel", GetDbgFwdBufStoreInfo(V, destChannelId_f, &buf_store_info))
    }
    if (GetDbgFwdBufStoreInfo(V, backPressureDiscard_f, &buf_store_info))
    {
        DIAG_INFO_CHAR(pos, "drop-desc", "back-pressure-discard")
        p_rslt->dest_type = CTC_DIAG_DEST_DROP;
    }
    if (GetDbgFwdBufStoreInfo(V, destIdDiscard_f, &buf_store_info))
    {
        DIAG_INFO_CHAR(pos, "drop-desc", "dest-id-discard")
        p_rslt->dest_type = CTC_DIAG_DEST_DROP;
    }
    if (GetDbgFwdBufStoreInfo(V, fwdCheckDiscard_f, &buf_store_info))
    {
        DIAG_INFO_CHAR(pos, "drop-desc", "forward-check-fail")
        p_rslt->dest_type = CTC_DIAG_DEST_DROP;
    }
#if (SDK_WORK_PLATFORM == 0)
    if (!GetDbgFwdBufStoreInfo(V, resourceCheckPass_f, &buf_store_info))
    {
        DIAG_INFO_CHAR(pos, "drop-desc", "resource-check-fail")
        p_rslt->dest_type = CTC_DIAG_DEST_DROP;
    }
#endif
    if (GetDbgFwdBufStoreInfo(V, noFifoDiscard_f, &buf_store_info))
    {
        DIAG_INFO_CHAR(pos, "drop-desc", "no-fifo")
        p_rslt->dest_type = CTC_DIAG_DEST_DROP;
    }

    return CTC_E_NONE;
}
STATIC int32
_sys_tmm_diag_pkt_trace_get_tm_met_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 count = 0;
    uint32 value = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_TM;
    char str[64] = {0};
    uint32 ucastId = 0;
    uint32 local_chip = 0;
    uint32 dsMetEntryBase = 0;
    uint32 groupIdShiftBit = 0;
    uint32 nextMetEntryPtr = 0;
    uint32 metEntryPtr = 0;
    uint32 nexthopPtr = 0;
    uint32 currentMetEntryType = 0;
    uint32 port_bitmap_high[2] = {0};
    uint32 port_bitmap_low[2] = {0};
    uint32 dest_map = 0;
    uint64 value_u64 = 0;
    DsMetEntry6W_m ds_met_entry6_w;
    DsMetEntry6W_m ds_met_entry;
    DbgFwdMetFifoInfo1_m met_fifo_info1;
    DbgFwdMetFifoInfo2_m met_fifo_info2;

    sal_memset(&ds_met_entry6_w, 0, sizeof(ds_met_entry6_w));
    sal_memset(&ds_met_entry, 0, sizeof(ds_met_entry));

    sal_memset(&met_fifo_info1, 0, sizeof(met_fifo_info1));
    cmd = DRV_IOR(DbgFwdMetFifoInfo1_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &met_fifo_info1));
    sal_memset(&met_fifo_info2, 0, sizeof(met_fifo_info2));
    cmd = DRV_IOR(DbgFwdMetFifoInfo2_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &met_fifo_info2));

    if (!GetDbgFwdMetFifoInfo1(V, valid_f, &met_fifo_info1))
    {
        return CTC_E_NONE;
    }
    p_rslt->position = CTC_DIAG_TRACE_POS_TM;
    DIAG_INFO_NONE(pos, "MetFifo")

    dest_map = GetDbgFwdMetFifoInfo1(V, destMap_f, &met_fifo_info1);
    DIAG_INFO_U32_HEX(pos, "dest-map", dest_map)
    if (!GetDbgFwdMetFifoInfo1(V, execMet_f, &met_fifo_info1))
    {
        DIAG_INFO_CHAR(pos, "forward-type", "UCAST")
        return CTC_E_NONE;
    }
    DIAG_INFO_CHAR(pos, "forward-type", "MCAST")
    DIAG_INFO_UINT32(pos, "mcast-group", dest_map & 0xFFFF)

    cmd = DRV_IOR(MetFifoCtl_t, MetFifoCtl_chipId_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &local_chip));
    cmd = DRV_IOR(MetFifoCtl_t, MetFifoCtl_dsMetEntryBase_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &dsMetEntryBase));
    cmd = DRV_IOR(MetFifoCtl_t, MetFifoCtl_groupIdShiftBit_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &groupIdShiftBit));

    nextMetEntryPtr = (dest_map&0xFFFF) << groupIdShiftBit;
    for (count = 0;count < 4096; count++)
    {
        metEntryPtr =  nextMetEntryPtr + dsMetEntryBase;
        cmd = DRV_IOR(DsMetEntry6W_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, (metEntryPtr&0x1FFFE), cmd, &ds_met_entry6_w));

        currentMetEntryType = GetDsMetEntry6W(V, currentMetEntryType_f, &ds_met_entry6_w);
        sal_sprintf(str, "met-entry-%d", count);
        DIAG_INFO_CHAR(pos, str, "HIT")
        DIAG_INFO_CHAR(pos, "table-name", currentMetEntryType ? "DsMetEntry6W" : "DsMetEntry3W")
        DIAG_INFO_UINT32(pos, "table-index", metEntryPtr)
        if (currentMetEntryType)
        {
            sal_memcpy((uint8*)&ds_met_entry, (uint8*)&ds_met_entry6_w, DRV_TABLE_ENTRY_SIZE(lchip, DsMetEntry6W_t));
        }
        else
        {
            if (CTC_IS_BIT_SET(metEntryPtr, 0))
            {
                sal_memcpy((uint8*)&ds_met_entry, ((uint8 *)&ds_met_entry6_w) + DRV_TABLE_ENTRY_SIZE(lchip, DsMetEntry3W_t), DRV_TABLE_ENTRY_SIZE(lchip, DsMetEntry3W_t));
            }
            else
            {
                sal_memcpy((uint8*)&ds_met_entry, ((uint8 *)&ds_met_entry6_w), DRV_TABLE_ENTRY_SIZE(lchip, DsMetEntry3W_t));
            }
            sal_memset(((uint8*)&ds_met_entry) + DRV_TABLE_ENTRY_SIZE(lchip, DsMetEntry3W_t), 0, DRV_TABLE_ENTRY_SIZE(lchip, DsMetEntry3W_t));
        }

        nextMetEntryPtr = GetDsMetEntry6W(V, nextMetEntryPtr_f, &ds_met_entry);
        ucastId = GetDsMetEntry6W(V, ucastId_f, &ds_met_entry);

        if (currentMetEntryType)
        {
            nexthopPtr = GetDsMetEntry6W(V, nextHopPtr_f, &ds_met_entry);
        }
        else
        {
            cmd = DRV_IOR(MetFifoCtl_t, MetFifoCtl_portBitmapNextHopPtr_f);
            CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &nexthopPtr));
        }

        if(GetDsMetEntry6W(V, remoteChip_f, &ds_met_entry))
        {
            DIAG_INFO_CHAR(pos, "to-remote-chip", "YES")
        }
        else
        {
            if (!GetDsMetEntry6W(V, mcastMode_f, &ds_met_entry) && GetDsMetEntry6W(V, apsBridgeEn_f, &ds_met_entry))
            {
                DIAG_INFO_CHAR(pos, "aps-bridge", "YES")
                DIAG_INFO_UINT32(pos, "aps-group", ucastId)
            }
            if (!GetDsMetEntry6W(V, mcastMode_f, &ds_met_entry))
            {
                DIAG_INFO_CHAR(pos, "met-mode", "link-list")
                if (GetDsMetEntry6W(V, isLinkAggregation_f, &ds_met_entry))
                {
                    DIAG_INFO_UINT32(pos, "linkagg-group", ucastId&CTC_LINKAGGID_MASK)
                }
                else
                {
                    if (!GetDsMetEntry6W(V, apsBridgeEn_f, &ds_met_entry))
                    {
                        DIAG_INFO_U32_HEX(pos, "dest-gport", CTC_MAP_LPORT_TO_GPORT(local_chip, ucastId&0x1FF))
                    }
                }
                value = GetDsMetEntry6W(V, replicationCtl_f, &ds_met_entry);
                DIAG_INFO_UINT32(pos, "replication-count", value&0x1F)
                DIAG_INFO_U32_HEX(pos, "nexthop-ptr", value >> 5)
            }
            else
            {
                GetDsMetEntry6W(A, portBitmapHigh_f, &ds_met_entry, port_bitmap_high);
                GetDsMetEntry6W(A, portBitmap_f, &ds_met_entry, port_bitmap_low);
                DIAG_INFO_CHAR(pos, "met-mode", "bitmap")
                if (GetDsMetEntry6W(V, isLinkAggregation_f, &ds_met_entry))
                {
                    DIAG_INFO_CHAR(pos, "bitmap-type", "linkagg-port")
                }
                else
                {
                    DIAG_INFO_CHAR(pos, "bitmap-type", "normal-gport")
                }
                DIAG_INFO_UINT32(pos, "port-bitmap-base", GetDsMetEntry6W(V, portBitmapBase_f, &ds_met_entry) << 6)
                value_u64 = port_bitmap_low[1];
                value_u64 = value_u64 << 32 | port_bitmap_low[0];
                DIAG_INFO_U64_HEX(pos, "dest-port-bitmap63~0", value_u64)
                if (currentMetEntryType)
                {
                    value_u64 = port_bitmap_high[1];
                    value_u64 = value_u64 << 32 | port_bitmap_high[0];
                    DIAG_INFO_U64_HEX(pos, "dest-port-bitmap127~64", value_u64)
                }
                DIAG_INFO_U32_HEX(pos, "nexthop-ptr", nexthopPtr)
            }
        }
        if (GetDbgFwdMetFifoInfo2(V, valid_f, &met_fifo_info2))
        {
            uint8  rep_ctl_utype = 0;
            uint8  pkt_type = 0;
            TempDsReplicationCtl_m rep_ctl;
            char* const pkt_type_desc[] = {
                    "ETHERNET", "IPV4", "MPLS",     "IPV6",
                    "MPLSUP",   "IP",   "FLEXIBLE", "RESERVED"
                };
            GetDbgFwdMetFifoInfo2(A, replicationCtl_f, &met_fifo_info2, &rep_ctl);
            rep_ctl_utype = GetTempDsReplicationCtl(V, uType_f, &rep_ctl);
            switch(rep_ctl_utype)
            {
                case 0: /*exception*/
                {
                    pkt_type = GetTempDsReplicationCtl(V, u_g0_exceptionPacketType_f, &rep_ctl);
                    DIAG_INFO_CHAR(pos, "exception-from-sgmac", GetTempDsReplicationCtl(V, u_g0_exceptionFromSgmac_f, &rep_ctl)? "Yes": "No")
                    DIAG_INFO_UINT32(pos, "exception-id", GetTempDsReplicationCtl(V, u_g0_exceptionId_f, &rep_ctl))
                    DIAG_INFO_CHAR(pos, "exception-packet-type", STR_ARRAY(pkt_type_desc,pkt_type))
                }
                break;
                case 1: /*nexthop*/
                {
                    DIAG_INFO_U32_HEX(pos, "rep-nexthop-ptr", GetTempDsReplicationCtl(V, u_g1_nextHopPtr_f, &rep_ctl))
                }
                break;
                case 2: /*replication*/
                {
                    DIAG_INFO_CHAR(pos, "last-rep", GetTempDsReplicationCtl(V, u_g2_lastRep_f, &rep_ctl)? "Yes": "No")
                    DIAG_INFO_U32_HEX(pos, "rep-hdr-ptr", GetTempDsReplicationCtl(V, u_g2_logicalRepHeadPtr_f, &rep_ctl))
                }
                break;
                default:
                break;
            }
        }
        if (0xFFFF == nextMetEntryPtr
            || GetDsMetEntry6W(V, endLocalRep_f, &ds_met_entry))
        {
            break;
        }
    }

    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_get_tm_queue_info(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 channel = 0;
    uint8 pos = CTC_DIAG_TRACE_POS_TM;
    DbgFwdQWriteInfo_m qwrite_info;
    DbgMmuErmInfo_m mmu_erm_info;

    sal_memset(&qwrite_info, 0, sizeof(DbgFwdQWriteInfo_m));
    cmd = DRV_IOR(DbgFwdQWriteInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &qwrite_info));
    sal_memset(&mmu_erm_info, 0, sizeof(DbgMmuErmInfo_m));
    cmd = DRV_IOR(DbgMmuErmInfo_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &mmu_erm_info));


    if (!GetDbgFwdQWriteInfo(V, valid_f, &qwrite_info))
    {
        return CTC_E_NONE;
    }
    DIAG_INFO_NONE(pos, "Queue")
    p_rslt->position = CTC_DIAG_TRACE_POS_TM;
    if (GetDbgFwdQWriteInfo(V, channelIdValid_f, &qwrite_info))
    {
        channel = GetDbgFwdQWriteInfo(V, channelId_f, &qwrite_info);
        DIAG_INFO_UINT32(pos, "channel-id", channel)
        if (!CTC_FLAG_ISSET(p_rslt->flags, CTC_DIAG_TRACE_RSTL_FLAG_MC_GROUP))
        {
            p_rslt->channel = channel;
            p_rslt->flags |= CTC_DIAG_TRACE_RSTL_FLAG_CHANNLE;
        }
        if (channel == MCHIP_CAP(SYS_CAP_CHANID_ILOOP))
        {
            p_rslt->loop_flags |= CTC_DIAG_LOOP_FLAG_ILOOP;
        }
        if (channel == MCHIP_CAP(SYS_CAP_CHANID_ELOOP))
        {
            p_rslt->loop_flags |= CTC_DIAG_LOOP_FLAG_ELOOP;
        }
    }
    if (GetDbgFwdQWriteInfo(V, noLinkAggregationMemberDiscard_f, &qwrite_info))
    {
        DIAG_INFO_CHAR(pos, "drop-desc", "port-linkagg-no-member")
        p_rslt->dest_type = CTC_DIAG_DEST_DROP;
    }
    else if (GetDbgFwdQWriteInfo(V, mcastLinkAggregationDiscard_f, &qwrite_info))
    {
        DIAG_INFO_CHAR(pos, "drop-desc", "mcast-linkagg-no-member")
        p_rslt->dest_type = CTC_DIAG_DEST_DROP;
    }
    else if (GetDbgFwdQWriteInfo(V, stackingDiscard_f, &qwrite_info))
    {
        DIAG_INFO_CHAR(pos, "drop-desc", "stacking-discard")
        p_rslt->dest_type = CTC_DIAG_DEST_DROP;
    }
    else if (GetDbgFwdQWriteInfo(V, lookupResultValid_f, &qwrite_info))
    {
        DIAG_INFO_UINT32(pos, "queue-id", GetDbgFwdQWriteInfo(V, mappedQueueId_f, &qwrite_info))
    }
    else
    {
        DIAG_INFO_UINT32(pos, "queue-id", GetDbgFwdQWriteInfo(V, queueId_f, &qwrite_info))
    }
    if (GetDbgFwdQWriteInfo(V, tcamResultValid_f, &qwrite_info))
    {
        DIAG_INFO_UINT32(pos, "tcam-hit-index", GetDbgFwdQWriteInfo(V, hitIndex_f, &qwrite_info))
    }
    if (GetDbgFwdQWriteInfo(V, cutThroughEn_f, &qwrite_info))
    {
        DIAG_INFO_CHAR(pos, "cut-through", "ENABLE")
    }

    /*lag process*/
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_lag_info(lchip, p_rslt));

    if (!GetDbgMmuErmInfo(V, valid_f, &mmu_erm_info))
    {
        return CTC_E_NONE;
    }
    if (!GetDbgMmuErmInfo(V, resourceCheckPass_f, &mmu_erm_info))
    {
        DIAG_INFO_CHAR(pos, "drop-desc", "enqueue-discard")
        p_rslt->dest_type = CTC_DIAG_DEST_DROP;
    }
    DIAG_INFO_UINT32(pos, "mapped-sc", GetDbgMmuErmInfo(V, mappedSc_f, &mmu_erm_info))
    DIAG_INFO_UINT32(pos, "mapped-tc", GetDbgMmuErmInfo(V, mappedTc_f, &mmu_erm_info))
    if (GetDbgMmuErmInfo(V, isC2cPacket_f, &mmu_erm_info))
    {
        DIAG_INFO_CHAR(pos, "is-c2c-packet", "TRUE")
    }
    if (GetDbgMmuErmInfo(V, isCriticalPacket_f, &mmu_erm_info))
    {
        DIAG_INFO_CHAR(pos, "is-critical-packet", "TRUE")
    }


    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_get_pkt_trace_pos_ipe(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;

    cmd = DRV_IOR(DbgIpeLkpMgrInfo_t, DbgIpeLkpMgrInfo_valid_f);
    DRV_FIELD_IOCTL(lchip, 0, cmd, &value);
    if (p_rslt->watch_point != CTC_DIAG_TRACE_POINT_IPE_SCL || value == 0)
    {
        return CTC_E_NONE;
    }
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_parser_info(lchip, 0, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipe_scl_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipe_intf_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipe_decap_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_parser_info(lchip, 1, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_lkup_mgr_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_flow_hash_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipe_bridge_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipe_route_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipe_fcoe_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipe_trill_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipe_phb_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipe_oam_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipe_acl_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipe_stmctl_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipe_policer_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipe_copp_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipe_learn_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipe_dest_info(lchip, p_rslt));
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_get_pkt_trace_pos_tm(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;

    cmd = DRV_IOR(DbgFwdBufStoreInfo_t, DbgFwdBufStoreInfo_valid_f);
    DRV_FIELD_IOCTL(lchip, 0, cmd, &value);
    if (p_rslt->dest_type == CTC_DIAG_DEST_DROP || value == 0)
    {
        return CTC_E_NONE;
    }
    if ((p_rslt->watch_point == CTC_DIAG_TRACE_POINT_IPE_SCL)
        || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_TM_BS)
        || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_OAM_TX))
    {
        CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_tm_bs_info(lchip, p_rslt));
    }
    if ((p_rslt->watch_point == CTC_DIAG_TRACE_POINT_IPE_SCL)
        || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_TM_BS)
        || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_TM_MET)
        || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_OAM_TX))
    {
        CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_tm_met_info(lchip, p_rslt));
        if (0 == (p_rslt->flags & CTC_DIAG_TRACE_RSTL_FLAG_MC_GROUP))
        {
            CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_tm_queue_info(lchip, p_rslt));
        }
    }
    return CTC_E_NONE;
}


STATIC int32
_sys_tmm_diag_get_pkt_trace_pos_epe(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;

    cmd = DRV_IOR(DbgEpeHdrAdjInfo_t, DbgEpeHdrAdjInfo_valid_f);
    DRV_FIELD_IOCTL(lchip, 0, cmd, &value);
    if (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_OAM_ADJ || value == 0)
    {
        return CTC_E_NONE;
    }
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_epe_hdj_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_parser_info(lchip, 2, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_epe_nh_map_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_epe_scl_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_epe_edit_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_epe_acl_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_epe_copp_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_ipfix_info(lchip, p_rslt, 1));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_epe_oam_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_epe_pkt_rw_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_epe_hdr_edit_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_epe_dot1ae_info(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_epe_hmac_info(lchip, p_rslt));
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_get_pkt_trace_pos_oam(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;

    if ((p_rslt->watch_point == CTC_DIAG_TRACE_POINT_IPE_SCL)
        || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_TM_BS)
        || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_TM_MET)
        || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_OAM_ADJ))
    {
        cmd = DRV_IOR(DbgOamHdrAdj_t, DbgOamHdrAdj_valid_f);
        DRV_FIELD_IOCTL(lchip, 0, cmd, &value);

        if(value == 0)
        {
            return CTC_E_NONE;
        }
        CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_oam_rx_info(lchip, p_rslt));
    }
    if (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_OAM_TX)
    {
        cmd = DRV_IOR(DbgOamTxProc_t, DbgOamTxProc_valid_f);
        DRV_FIELD_IOCTL(lchip, 0, cmd, &value);
        if(value == 0)
        {
            return CTC_E_NONE;
        }
        CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_oam_tx_info(lchip, p_rslt));
    }
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_get_pkt_trace_pos_sc_oam(uint8 lchip, ctc_diag_pkt_trace_result_t* p_rslt)
{
    uint32 cmd = 0;
    uint32 value = 0;

    if ((p_rslt->watch_point == CTC_DIAG_TRACE_POINT_IPE_SCL)
        || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_TM_BS)
    || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_TM_MET)
    || (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_SC_OAM_RX))
    {
        cmd = DRV_IOR(DbgFlexEOamRxProc_t, DbgFlexEOamRxProc_valid_f);
        DRV_FIELD_IOCTL(lchip, 0, cmd, &value);
        if (value == 0)
        {
            return CTC_E_NONE;
        }
        CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_sc_oam_rx_info(lchip, p_rslt));
    }
    if (p_rslt->watch_point == CTC_DIAG_TRACE_POINT_SC_OAM_TX)
    {
        cmd = DRV_IOR(DbgFlexEOamTxProc_t, DbgFlexEOamTxProc_valid_f);
        DRV_FIELD_IOCTL(lchip, 0, cmd, &value);
        if (value == 0)
        {
            return CTC_E_NONE;
        }
        CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_get_sc_oam_tx_info(lchip, p_rslt));
    }
    return CTC_E_NONE;
}

STATIC int32
_sys_tmm_diag_pkt_trace_clear_rslt(uint8 lchip, uint32 watch_point)
{
    uint32 loop = 0;
    uint32 loop_size = 0;
    uint32 cmd = 0;
    ds_t temp_v;
    IpeUserIdFlowLoopCam_m ds_flow_loop_cam;
    BufStoreDebugCam_m ds_buff_store_cam;
    MetFifoDebugCam_m ds_met_fifo_cam;
    EpeHdrAdjustDebugCam_m ds_epe_dbg_cam;

    static sys_diag_pkt_trace_table_t ipe_tbl[] =
    {
        {DbgFibLkpEngineFlowHashInfo_t, DbgFibLkpEngineFlowHashInfo_valid_f},
        {DbgFibLkpEngineHostUrpfHashInfo_t, DbgFibLkpEngineHostUrpfHashInfo_valid_f},
        {DbgLpmPipelineLookupResultInfo_t, DbgLpmPipelineLookupResultInfo_valid_f},
        {DbgIpeFwdInputHeaderInfo_t, DbgIpeFwdInputHeaderInfo_valid_f},
        {DbgFibLkpEngineMacDaHashInfo_t, DbgFibLkpEngineMacDaHashInfo_valid_f},
        {DbgFibLkpEngineMacSaHashInfo_t, DbgFibLkpEngineMacSaHashInfo_valid_f},
        {DbgFibLkpEnginel3DaHashInfo_t, DbgFibLkpEnginel3DaHashInfo_valid_f},
        {DbgFibLkpEnginel3SaHashInfo_t, DbgFibLkpEnginel3SaHashInfo_valid_f},
        {DbgFibLkpEngineTcamKeyInfo_t, DbgFibLkpEngineTcamKeyInfo_valid_f},
        {DbgIpfixAccInfo0_t, DbgIpfixAccInfo0_valid_f},
        {DbgIpfixAccInfo1_t, DbgIpfixAccInfo1_valid_f},
        {DbgFlowTcamEngineEpeAclKeyInfo0_t, DbgFlowTcamEngineEpeAclKeyInfo0_valid_f},
        {DbgFlowTcamEngineEpeAclKeyInfo1_t, DbgFlowTcamEngineEpeAclKeyInfo1_valid_f},
        {DbgFlowTcamEngineEpeAclKeyInfo2_t, DbgFlowTcamEngineEpeAclKeyInfo2_valid_f},
        {DbgFlowTcamEngineEpeAclKeyInfo3_t, DbgFlowTcamEngineEpeAclKeyInfo3_valid_f},
        {DbgProgramLtidTcamEngineIpeAclKeyInfo_t, DbgProgramLtidTcamEngineIpeAclKeyInfo_valid_f},
        {DbgProgramLtidTcamEngineIpeAclInfo_t, DbgProgramLtidTcamEngineIpeAclInfo_valid_f},
        {DbgProgramAclTcamEngineIpeAclKeyInfo0_t, DbgProgramAclTcamEngineIpeAclKeyInfo0_valid_f},
        {DbgProgramAclTcamEngineIpeAclKeyInfo1_t, DbgProgramAclTcamEngineIpeAclKeyInfo1_valid_f},
        {DbgProgramAclTcamEngineIpeAclKeyInfo2_t, DbgProgramAclTcamEngineIpeAclKeyInfo2_valid_f},
        {DbgProgramAclTcamEngineIpeAclKeyInfo3_t, DbgProgramAclTcamEngineIpeAclKeyInfo3_valid_f},
        {DbgProgramAclTcamEngineIpeAclKeyInfo4_t, DbgProgramAclTcamEngineIpeAclKeyInfo4_valid_f},
        {DbgProgramAclTcamEngineIpeAclKeyInfo5_t, DbgProgramAclTcamEngineIpeAclKeyInfo5_valid_f},
        {DbgProgramAclTcamEngineIpeAclKeyInfo6_t, DbgProgramAclTcamEngineIpeAclKeyInfo6_valid_f},
        {DbgProgramAclTcamEngineIpeAclKeyInfo7_t, DbgProgramAclTcamEngineIpeAclKeyInfo7_valid_f},
        {DbgProgramAclTcamEngineIpeAclKeyInfo8_t, DbgProgramAclTcamEngineIpeAclKeyInfo8_valid_f},
        {DbgProgramAclTcamEngineIpeAclKeyInfo9_t, DbgProgramAclTcamEngineIpeAclKeyInfo9_valid_f},
        {DbgProgramAclTcamEngineIpeAclKeyInfo10_t, DbgProgramAclTcamEngineIpeAclKeyInfo10_valid_f},
        {DbgProgramAclTcamEngineIpeAclKeyInfo11_t, DbgProgramAclTcamEngineIpeAclKeyInfo11_valid_f},
        {DbgProgramAclTcamEngineIpeAclKeyInfo12_t, DbgProgramAclTcamEngineIpeAclKeyInfo12_valid_f},
        {DbgProgramAclTcamEngineIpeAclKeyInfo13_t, DbgProgramAclTcamEngineIpeAclKeyInfo13_valid_f},
        {DbgProgramAclTcamEngineIpeAclKeyInfo14_t, DbgProgramAclTcamEngineIpeAclKeyInfo14_valid_f},
        {DbgProgramAclTcamEngineIpeAclKeyInfo15_t, DbgProgramAclTcamEngineIpeAclKeyInfo15_valid_f},
        {DbgProgramAclTcamEngineIpeAclInfo0_t, DbgProgramAclTcamEngineIpeAclInfo0_valid_f},
        {DbgProgramAclTcamEngineIpeAclInfo1_t, DbgProgramAclTcamEngineIpeAclInfo1_valid_f},
        {DbgProgramAclTcamEngineIpeAclInfo2_t, DbgProgramAclTcamEngineIpeAclInfo2_valid_f},
        {DbgProgramAclTcamEngineIpeAclInfo3_t, DbgProgramAclTcamEngineIpeAclInfo3_valid_f},
        {DbgProgramAclTcamEngineIpeAclInfo4_t, DbgProgramAclTcamEngineIpeAclInfo4_valid_f},
        {DbgProgramAclTcamEngineIpeAclInfo5_t, DbgProgramAclTcamEngineIpeAclInfo5_valid_f},
        {DbgProgramAclTcamEngineIpeAclInfo6_t, DbgProgramAclTcamEngineIpeAclInfo6_valid_f},
        {DbgProgramAclTcamEngineIpeAclInfo7_t, DbgProgramAclTcamEngineIpeAclInfo7_valid_f},
        {DbgProgramAclTcamEngineIpeAclInfo8_t, DbgProgramAclTcamEngineIpeAclInfo8_valid_f},
        {DbgProgramAclTcamEngineIpeAclInfo9_t, DbgProgramAclTcamEngineIpeAclInfo9_valid_f},
        {DbgProgramAclTcamEngineIpeAclInfo10_t, DbgProgramAclTcamEngineIpeAclInfo10_valid_f},
        {DbgProgramAclTcamEngineIpeAclInfo11_t, DbgProgramAclTcamEngineIpeAclInfo11_valid_f},
        {DbgProgramAclTcamEngineIpeAclInfo12_t, DbgProgramAclTcamEngineIpeAclInfo12_valid_f},
        {DbgProgramAclTcamEngineIpeAclInfo13_t, DbgProgramAclTcamEngineIpeAclInfo13_valid_f},
        {DbgProgramAclTcamEngineIpeAclInfo14_t, DbgProgramAclTcamEngineIpeAclInfo14_valid_f},
        {DbgProgramAclTcamEngineIpeAclInfo15_t, DbgProgramAclTcamEngineIpeAclInfo15_valid_f},
        {DbgUserIdHashEngineForUserId0Info_t, DbgUserIdHashEngineForUserId0Info_valid_f},
        {DbgUserIdHashEngineForUserId1Info_t, DbgUserIdHashEngineForUserId1Info_valid_f},
        {DbgUserIdTcamEngineForUserId0Info_t, DbgUserIdTcamEngineForUserId0Info_valid_f},
        {DbgUserIdTcamEngineForUserId1Info_t, DbgUserIdTcamEngineForUserId1Info_valid_f},
        {DbgIpeEcmpProcInfo_t, DbgIpeEcmpProcInfo_valid_f},
        {DbgIpeFwdCoppInfo_t, DbgIpeFwdCoppInfo_valid_f},
        {DbgIpeFwdPolicingInfo_t, DbgIpeFwdPolicingInfo_valid_f},
        {DbgIpeFwdProcessInfo_t, DbgIpeFwdProcessInfo_valid_f},
        {DbgIpeAclProcInfo0_t, DbgIpeAclProcInfo0_valid_f},
        {DbgIpeAclProcInfo1_t, DbgIpeAclProcInfo1_valid_f},
        {DbgIpeFwdStormCtlInfo_t, DbgIpeFwdStormCtlInfo_valid_f},
        {DbgIpeIntfMapperInfo_t, DbgIpeIntfMapperInfo_valid_f},
        {DbgIpeMplsDecapInfo_t, DbgIpeMplsDecapInfo_valid_f},
        {DbgIpeUserIdInfo_t, DbgIpeUserIdInfo_valid_f},
        {DbgIpeLkpMgrInfo_t, DbgIpeLkpMgrInfo_valid_f},
        {DbgParserFromIpeIntfInfo_t, DbgParserFromIpeIntfInfo_valid_f},
        {DbgIpeFcoeInfo_t, DbgIpeFcoeInfo_valid_f},
        {DbgIpeFlowProcessInfo_t, DbgIpeFlowProcessInfo_valid_f},
        {DbgIpeIpRoutingInfo_t, DbgIpeIpRoutingInfo_valid_f},
        {DbgIpeMacBridgingInfo_t, DbgIpeMacBridgingInfo_valid_f},
        {DbgIpeMacLearningInfo_t, DbgIpeMacLearningInfo_valid_f},
        {DbgIpeOamInfo_t, DbgIpeOamInfo_valid_f},
        {DbgIpePacketProcessInfo_t, DbgIpePacketProcessInfo_valid_f},
        {DbgIpePerHopBehaviorInfo_t, DbgIpePerHopBehaviorInfo_valid_f},
        {DbgIpeTrillInfo_t, DbgIpeTrillInfo_valid_f},
        {DbgLagEngineInfo_t, DbgLagEngineInfo_valid_f},
        {DbgLpmTcamEngineResult0Info_t, DbgLpmTcamEngineResult0Info_valid_f},
        {DbgLpmTcamEngineResult1Info_t, DbgLpmTcamEngineResult1Info_valid_f},
        {DbgParserFromIpeHdrAdjInfo_t, DbgParserFromIpeHdrAdjInfo_valid_f},
        {DbgUserIdHashEngineForUserId0Info_t, DbgUserIdHashEngineForUserId0Info_valid_f},
        {DbgUserIdHashEngineForUserId1Info_t, DbgUserIdHashEngineForUserId1Info_valid_f},
        {DbgEfdEngineInfo_t, DbgEfdEngineInfo_valid_f},
        {DbgFibLkpEngineFibHashInfo_t, DbgFibLkpEngineFibHashInfo_valid_f},
        {DbgFibLkpEngineFibHost0KeyInfo_t, DbgFibLkpEngineFibHost0KeyInfo_valid_f},
        {DbgEcmpDlbEngineInfo_t, DbgEcmpDlbEngineInfo_valid_f},
        {DbgIpeLookupManagerOuterL2Decoder_t, DbgIpeLookupManagerOuterL2Decoder_valid_f},
        {DbgMplsHashEngineForLabel0Info_t, DbgMplsHashEngineForLabel0Info_valid_f},
        {DbgMplsHashEngineForLabel1Info_t, DbgMplsHashEngineForLabel1Info_valid_f},
        {DbgMplsHashEngineForLabel2Info_t, DbgMplsHashEngineForLabel2Info_valid_f},
        {IpeUserIdFlowCtl_t, IpeUserIdFlowCtl_flowEn_f},
        {DbgSCLEngineUdfDecoderInfo_t,DbgSCLEngineUdfDecoderInfo_valid_f},
        {DbgIpeLookupManagerUdfDecoder_t,DbgIpeLookupManagerUdfDecoder_valid_f},
        {IpeUserIdFlowCam_t, IpeUserIdFlowCam_g_0_isDebuggedPkt_f},
        {IpeUserIdFlowCam_t, IpeUserIdFlowCam_g_1_isDebuggedPkt_f},
        {IpeUserIdFlowCam_t, IpeUserIdFlowCam_g_0_data_f},
        {IpeUserIdFlowCam_t, IpeUserIdFlowCam_g_1_data_f},
        {DbgIpeLookupManagerInnerL2Decoder_t, DbgIpeLookupManagerInnerL2Decoder_valid_f},
        {DbgIpeLookupManagerInnerL3Decoder_t, DbgIpeLookupManagerInnerL3Decoder_valid_f},
        {DbgIpeLookupManagerInnerL4Decoder_t, DbgIpeLookupManagerInnerL4Decoder_valid_f},
        {DbgIpeLookupManagerOuterL3Decoder_t, DbgIpeLookupManagerOuterL3Decoder_valid_f},
        {DbgIpeLookupManagerOuterL4Decoder_t, DbgIpeLookupManagerOuterL4Decoder_valid_f},
        {DbgSCLEngineDecoderSclInputInfo_t, DbgSCLEngineDecoderSclInputInfo_valid_f},
        {DbgSCLEngineL2DecoderInfo_t, DbgSCLEngineL2DecoderInfo_valid_f},
        {DbgSCLEngineL3DecoderInfo_t, DbgSCLEngineL3DecoderInfo_valid_f},
        {DbgSCLEngineL4DecoderInfo_t, DbgSCLEngineL4DecoderInfo_valid_f},
        {DbgFibLkpEngineFibHost1KeyInfo_t, DbgFibLkpEngineFibHost1KeyInfo_valid_f}
    };

    sys_diag_pkt_trace_table_t bsr_tbl[] =
    {
        {DbgFwdBufStoreInfo2_t, DbgFwdBufStoreInfo2_valid_f},
        {DbgFwdBufStoreInfo_t, DbgFwdBufStoreInfo_valid_f},
        {BufStoreDebugCtl_t, BufStoreDebugCtl_debugLookupEn_f}
    };
    static sys_diag_pkt_trace_table_t epe_tbl[] =
    {
        {DbgOamHashEngineFromEpeOam0Info_t, DbgOamHashEngineFromEpeOam0Info_valid_f},
        {DbgOamHashEngineFromEpeOam1Info_t, DbgOamHashEngineFromEpeOam1Info_valid_f},
        {DbgOamHashEngineFromEpeOam2Info_t, DbgOamHashEngineFromEpeOam2Info_valid_f},
        {DbgOamHashEngineFromIpeOam0Info_t, DbgOamHashEngineFromIpeOam0Info_valid_f},
        {DbgOamHashEngineFromIpeOam1Info_t, DbgOamHashEngineFromIpeOam1Info_valid_f},
        {DbgOamHashEngineFromIpeOam2Info_t, DbgOamHashEngineFromIpeOam2Info_valid_f},
        {DbgEpeAclInfo_t, DbgEpeAclInfo_valid_f},
        {DbgEpeClassificationInfo_t, DbgEpeClassificationInfo_valid_f},
        {DbgEpeOamInfo_t, DbgEpeOamInfo_valid_f},
        {DbgEpeHdrAdjInfo_t, DbgEpeHdrAdjInfo_valid_f},
        {DbgEpeHdrEditCflexHdrInfo_t, DbgEpeHdrEditCflexHdrInfo_valid_f},
        {DbgEpeHdrEditInfo_t, DbgEpeHdrEditInfo_valid_f},
        {DbgEpeEgressEditInfo_t, DbgEpeEgressEditInfo_valid_f},
        {DbgEpePldProcInfo_t, DbgEpePldProcInfo_valid_f},
        {DbgParserFromEpeHdrAdjInfo_t, DbgParserFromEpeHdrAdjInfo_valid_f},
        {DbgEpeNextHopInfo_t, DbgEpeNextHopInfo_valid_f},
        {DbgEpeHdrAdjInfo0_t, DbgEpeHdrAdjInfo0_valid_f},
        {DbgEpeHdrAdjHeaderInfo_t, DbgEpeHdrAdjHeaderInfo_valid_f},
        {DbgEpeCoPPInfo_t, DbgEpeCoPPInfo_valid_f},
        {DbgEpePktRwInfo_t, DbgEpePktRwInfo_valid_f},
        {DbgEpeHdrEditHeaderInfo_t, DbgEpeHdrEditHeaderInfo_valid_f},
        {DbgEgrSclHash0_t, DbgEgrSclHash0_valid_f},
        {DbgEgrSclHash1_t, DbgEgrSclHash1_valid_f},
        {DbgMacsecTxInfo_t, DbgMacsecTxInfo_valid_f},
        {DbgFlowTcamEngineEpeAclInfo_t, DbgFlowTcamEngineEpeAclInfo_valid_f},
        {DbgHmacInfo_t, DbgHmacInfo_valid_f},
        {EpeHdrAdjustCtl_t, EpeHdrAdjustCtl_debugLookupEn_f}
    };
    sys_diag_pkt_trace_table_t met_tbl[] =
    {
        {DbgFwdMetFifoInfo1_t, DbgFwdMetFifoInfo1_valid_f},
        {DbgFwdMetFifoInfo2_t, DbgFwdMetFifoInfo2_valid_f},
        {DbgMmuErmInfo_t, DbgMmuErmInfo_valid_f},
        {DbgFwdQWriteInfo_t, DbgFwdQWriteInfo_valid_f},
        {MetFifoCtl_t, MetFifoCtl_debugLookupEn_f},
        {DbgFwdBufStoreInfo2_t, DbgFwdBufStoreInfo2_valid_f},
        {DbgFwdBufStoreInfo_t, DbgFwdBufStoreInfo_valid_f}
    };
    sys_diag_pkt_trace_table_t oam_rx_tbl[] =
    {
        {DbgOamHdrEdit_t, DbgOamHdrEdit_valid_f},
        {DbgOamHdrAdj_t, DbgOamHdrAdj_valid_f},
        {DbgOamParser_t, DbgOamParser_valid_f},
        {DbgOamDefectProc_t, DbgOamDefectProc_valid_f},
        {DbgOamRxProc_t, DbgOamRxProc_valid_f},
        {DbgOamApsSwitch_t, DbgOamApsSwitch_valid_f},
        {DbgOamApsProcess_t, DbgOamApsProcess_valid_f},
        {DbgOamRmepHashInfo_t, DbgOamRmepHashInfo_valid_f}
    };

    sys_diag_pkt_trace_table_t oam_tx_tbl[] =
    {
        {DbgOamTxProc_t, DbgOamTxProc_valid_f},
    };
    sys_diag_pkt_trace_table_t sc_oam_rx_tbl[] =
    {
        {DbgFlexEOamParser_t, DbgFlexEOamParser_valid_f},
        {DbgFlexEOamPktEdit_t, DbgFlexEOamPktEdit_valid_f},
        {DbgFlexEOamRxProc_t, DbgFlexEOamRxProc_valid_f}
    };
    sys_diag_pkt_trace_table_t sc_oam_tx_tbl[] =
    {
        {DbgFlexEOamTxProc_t, DbgFlexEOamTxProc_valid_f},
    };
    sal_memset(temp_v, 0, sizeof(ds_t));

    switch (watch_point)
    {
        case CTC_DIAG_TRACE_POINT_IPE_SCL:
            loop_size = sizeof(oam_rx_tbl)/sizeof(sys_diag_pkt_trace_table_t);
            for (loop = 0; loop < loop_size; loop++)
            {
                cmd = DRV_IOW(oam_rx_tbl[loop].table, oam_rx_tbl[loop].field);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, temp_v));
            }
            goto clear_ipe;
        case CTC_DIAG_TRACE_POINT_TM_BS:
            goto clear_bsr;
        case CTC_DIAG_TRACE_POINT_TM_MET:
            goto clear_met;
        case CTC_DIAG_TRACE_POINT_EPE_ADJ:
            goto clear_epe;
        case CTC_DIAG_TRACE_POINT_OAM_ADJ:
            loop_size = sizeof(oam_rx_tbl)/sizeof(sys_diag_pkt_trace_table_t);
            for (loop = 0; loop < loop_size; loop++)
            {
                cmd = DRV_IOW(oam_rx_tbl[loop].table, oam_rx_tbl[loop].field);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, temp_v));
            }
            break;
        case CTC_DIAG_TRACE_POINT_OAM_TX:
            loop_size = sizeof(oam_tx_tbl)/sizeof(sys_diag_pkt_trace_table_t);
            for (loop = 0; loop < loop_size; loop++)
            {
                cmd = DRV_IOW(oam_tx_tbl[loop].table, oam_tx_tbl[loop].field);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, temp_v));
            }
            goto clear_bsr;
            break;
        case CTC_DIAG_TRACE_POINT_SC_OAM_RX:
            loop_size = sizeof(sc_oam_rx_tbl)/sizeof(sys_diag_pkt_trace_table_t);
            for (loop = 0; loop < loop_size; loop++)
            {
                cmd = DRV_IOW(sc_oam_rx_tbl[loop].table, sc_oam_rx_tbl[loop].field);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, temp_v));
            }
            break;
        case CTC_DIAG_TRACE_POINT_SC_OAM_TX:
            loop_size = sizeof(sc_oam_tx_tbl)/sizeof(sys_diag_pkt_trace_table_t);
            for (loop = 0; loop < loop_size; loop++)
            {
                cmd = DRV_IOW(sc_oam_tx_tbl[loop].table, sc_oam_tx_tbl[loop].field);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, temp_v));
            }
            goto clear_bsr;
            break;
        default:
            break;
    }
    return CTC_E_NONE;

clear_ipe:
    sal_memset(&ds_flow_loop_cam, 0, sizeof(IpeUserIdFlowLoopCam_m));
    cmd = DRV_IOW(IpeUserIdFlowLoopCam_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ds_flow_loop_cam));

    loop_size = sizeof(ipe_tbl)/sizeof(sys_diag_pkt_trace_table_t);
    for (loop = 0; loop < loop_size; loop++)
    {
        cmd = DRV_IOW(ipe_tbl[loop].table, ipe_tbl[loop].field);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &temp_v));
    }

    loop_size = sizeof(oam_rx_tbl)/sizeof(sys_diag_pkt_trace_table_t);
    for (loop = 0; loop < loop_size; loop++)
    {
        cmd = DRV_IOW(oam_rx_tbl[loop].table, oam_rx_tbl[loop].field);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &temp_v));
    }
    loop_size = sizeof(oam_tx_tbl)/sizeof(sys_diag_pkt_trace_table_t);
    for (loop = 0; loop < loop_size; loop++)
    {
        cmd = DRV_IOW(oam_tx_tbl[loop].table, oam_tx_tbl[loop].field);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &temp_v));
    }

clear_bsr:
    sal_memset(&ds_buff_store_cam, 0, sizeof(BufStoreDebugCam_m));
    cmd = DRV_IOW(BufStoreDebugCam_t, DRV_ENTRY_FLAG);
    SYS_SET_TBL_ALL_DP(lchip, cmd, ds_buff_store_cam);

    loop_size = sizeof(bsr_tbl)/sizeof(sys_diag_pkt_trace_table_t);
    for (loop = 0; loop < loop_size; loop++)
    {
        cmd = DRV_IOW(bsr_tbl[loop].table, bsr_tbl[loop].field);
        SYS_SET_FIELD_TBL_ALL_DP(lchip, cmd, temp_v);
    }

clear_met:
    sal_memset(&ds_met_fifo_cam, 0, sizeof(MetFifoDebugCam_m));
    cmd = DRV_IOW(MetFifoDebugCam_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ds_met_fifo_cam));
    loop_size = sizeof(met_tbl)/sizeof(sys_diag_pkt_trace_table_t);
    for (loop = 0; loop < loop_size; loop++)
    {
        cmd = DRV_IOW(met_tbl[loop].table, met_tbl[loop].field);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &temp_v));
    }
clear_epe:
    sal_memset(&ds_epe_dbg_cam, 0, sizeof(EpeHdrAdjustDebugCam_m));
    cmd = DRV_IOW(EpeHdrAdjustDebugCam_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ds_epe_dbg_cam));

    loop_size = sizeof(epe_tbl)/sizeof(sys_diag_pkt_trace_table_t);
    for (loop = 0; loop < loop_size; loop++)
    {
        cmd = DRV_IOW(epe_tbl[loop].table, epe_tbl[loop].field);
        CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &temp_v));
    }

    return CTC_E_NONE;
}


STATIC int32
_sys_tmm_diag_get_drop_info(uint8 lchip, ctc_diag_drop_t* p_drop)
{
    uint32 cmd = 0;
    uint16 lport = 0;
    uint8 gchip = 0;
    uint32 value[48] = {0};
    uint32 chan_id = 0;
    uint32 loop_reason = 0;
    DsIngressDiscardStats_m  ds_igs_stats;
    DsEgressDiscardStats_m  ds_egs_stats;
    uint32 mac_id = 0;
    uint32 start_lport = 0;
    uint32 end_lport = MCHIP_CAP(SYS_CAP_PORT_NUM_PER_CHIP) - 1;
    uint32 index = 0;
    uint8 get_detail_en = 0;
    uint16 user_reason = 0;
    uint16 drop_reason = 0;
    uint32 p_data[15] = {0};
    drv_work_platform_type_t platform_type = 0;
    sys_usw_dmps_port_info_t dmps_port_info = {0};
    NetRxDebugStatsTable_m net_rx_debug_stats_table;
    NetRxDebugStats_m net_rx_debug_stats;
    BufStorePktErrStatsMem_m       pkt_err_stats_mem;
    NetTxDebugStats_m net_tx_debug_stats;
    BufStoreDebugStats_m  bsr_debug_stats;
    BufRetrvDPDebugStats_m  buf_retrv_dp_debug_stats;
    EpeScheduleDebugStats_m epe_sch_debug_stats;
    EpeHdrProcDebugStats_m epe_hdr_proc_debug_stats;
    BufStoreStallDropCntSaturation_m bsr_stall_drop_cnt;
    QMgrErmDebugStats_m qmgr_erm_debug_stats;
    QMgrQWriteDebugStats_m qmgr_qwrite_stats;
    MetFifoProcDebugStats_m met_proc_stats;

    drv_get_gchip_id(lchip, &gchip);
    CTC_ERROR_RETURN(drv_get_platform_type(lchip, &platform_type));

    if (p_drop->oper_type != CTC_DIAG_DROP_OPER_TYPE_GET_PORT_BMP)
    {
        if (p_drop->lport == SYS_DIAG_DROP_COUNT_SYSTEM)
        {
            goto get_system_stats;
        }
        start_lport = p_drop->lport;
        end_lport = start_lport;

    }
    if (p_drop->oper_type == CTC_DIAG_DROP_OPER_TYPE_GET_DETAIL_INFO)
    {
        user_reason = p_drop->reason;
        get_detail_en = 1;
    }

    sal_memset(&ds_igs_stats, 0, sizeof(ds_igs_stats));
    sal_memset(&ds_egs_stats, 0, sizeof(ds_egs_stats));

    for (lport = start_lport; lport <= end_lport; lport++)
    {
        /* IPE feature discard*/
        if(p_drop->dir == CTC_INGRESS || p_drop->dir == CTC_BOTH_DIRECTION)
        {
            for (loop_reason = SYS_TMM_DISCARD_IPE_START; loop_reason <= SYS_TMM_DISCARD_IPE_END; loop_reason++)
            {
                sys_tmm_map_drop_reason_sys_to_ctc(loop_reason, &drop_reason);
                if (get_detail_en && (user_reason != drop_reason))
                {
                    continue;
                }
                SYS_DIAG_DBG_OUT(CTC_DEBUG_LEVEL_INFO, "ipe_drop_reason:%u, discard_type:%u!\n", drop_reason, loop_reason);
                index = (lport << 6) + loop_reason - SYS_TMM_DISCARD_IPE_START;
                cmd = DRV_IOR(DsIngressDiscardStats_t, DsIngressDiscardStats_packetCount_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, index, cmd, &value[0]));
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, loop_reason, value[0]));
                if (SW_SIM_PLATFORM == platform_type)
                {
                    cmd = DRV_IOW(DsIngressDiscardStats_t, DRV_ENTRY_FLAG);
                    DRV_IOCTL(lchip, index, cmd, &ds_igs_stats);
                }
            }
        }

        /* EPE feature discard*/
        if(p_drop->dir == CTC_EGRESS || p_drop->dir == CTC_BOTH_DIRECTION)
        {
            for (loop_reason = SYS_TMM_DISCARD_EPE_START; loop_reason <= SYS_TMM_DISCARD_EPE_END; loop_reason++)
            {
                sys_tmm_map_drop_reason_sys_to_ctc(loop_reason, &drop_reason);
                if (get_detail_en && (user_reason != drop_reason))
                {
                    continue;
                }
                SYS_DIAG_DBG_OUT(CTC_DEBUG_LEVEL_INFO, "epe_drop_reason:%u, discard_type:%u!\n", drop_reason, loop_reason);
                index = (lport << 6) + loop_reason - SYS_TMM_DISCARD_EPE_START;
                cmd = DRV_IOR(DsEgressDiscardStats_t, DsEgressDiscardStats_packetCount_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, index, cmd, &value[0]));
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, loop_reason, value[0]));
                if (SW_SIM_PLATFORM == platform_type)
                {
                    cmd = DRV_IOW(DsEgressDiscardStats_t, DRV_ENTRY_FLAG);
                    DRV_IOCTL(lchip, index, cmd, &ds_egs_stats);
                }
            }
        }

        /*bufferstore */
        dmps_port_info.gport = CTC_MAP_LPORT_TO_GPORT(gchip, lport);
        CTC_ERROR_RETURN(sys_usw_port_api_get_dmps_property(lchip, &dmps_port_info, SYS_PORT_API_DMPS_PROP_CHAN_ID, &chan_id));
        cmd = DRV_IOR(BufStorePktErrStatsMem_t, DRV_ENTRY_FLAG);
        if(!(get_detail_en && (user_reason != CTC_DROP_TRAFFIC_MANAGER)))
        {
            if(chan_id != 0xFF && SYS_DMPS_INVALID_CHAN_ID != chan_id)
            {
                CTC_ERROR_RETURN(DRV_IOCTL(lchip, chan_id, cmd, &pkt_err_stats_mem));
                GetBufStorePktErrStatsMem(A, pktAbortCnt_f, &pkt_err_stats_mem, &value[0]);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_BUFSTORE_ABORT_TOTAL, value[0]));
                value[0] = GetBufStorePktErrStatsMem(V, pktAbortOverLenErrorCnt_f, &pkt_err_stats_mem) +
                        GetBufStorePktErrStatsMem(V, pktSilentDropUnderLenError_f, &pkt_err_stats_mem);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_BUFSTORE_LEN_ERROR, value[0]));
                GetBufStorePktErrStatsMem(A, pktSilentDropCnt_f, &pkt_err_stats_mem, &value[0]);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_BUFSTORE_SLIENT_TOTAL, value[0]));
                GetBufStorePktErrStatsMem(A, pktSilentDropResrcFailCnt_f, &pkt_err_stats_mem, &value[0]);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_BUFSTORE_IRM_RESRC, value[0]));
                value[0] = GetBufStorePktErrStatsMem(V, pktAbortDataErrorCnt_f, &pkt_err_stats_mem) +
                        GetBufStorePktErrStatsMem(V, pktSilentDropDataErrorCnt_f, &pkt_err_stats_mem);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_BUFSTORE_DATA_ERR, value[0]));
                GetBufStorePktErrStatsMem(A, pktSilentDropHardDiscardCnt_f, &pkt_err_stats_mem, &value[0]);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_BUFSTORE_HW_ERR, value[0]));
                GetBufStorePktErrStatsMem(A, pktSilentDropSelfOrigDiscardCnt_f, &pkt_err_stats_mem, &value[0]);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_BUFSTORE_CHIP_MISMATCH, value[0]));
                value[0] = GetBufStorePktErrStatsMem(V, pktAbortNoBufCnt_f, &pkt_err_stats_mem) +
                        GetBufStorePktErrStatsMem(V, pktSilentDropNoBufCnt_f, &pkt_err_stats_mem);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_BUFSTORE_NO_BUFF, value[0]));
                GetBufStorePktErrStatsMem(A, pktAbortFramingErrorCnt_f, &pkt_err_stats_mem, &value[0]);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_BUFSTORE_NO_EOP, value[0]));
                value[0] = GetBufStorePktErrStatsMem(V, pktAbortMetFifoDropCnt_f, &pkt_err_stats_mem) +
                        GetBufStorePktErrStatsMem(V, pktSilentDropMetFullDropCnt_f, &pkt_err_stats_mem);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_METFIFO_STALL_TO_BS_DROP, value[0]));
            }
        }

        CTC_ERROR_RETURN(sys_usw_port_api_get_dmps_property(lchip, &dmps_port_info, SYS_PORT_API_DMPS_PROP_MAC_ID, &mac_id));
        if (!(get_detail_en && (user_reason != CTC_DROP_NET_RX)))
        {
            if (mac_id != 0xFF && (mac_id> SYS_CPU_MAC_ID_MAX || mac_id < SYS_CPU_MAC_ID_MIN) && mac_id != DMPS_INVALID_VALUE_U32)
            {
                /*read net rx discard stats*/
                sal_memset(&net_rx_debug_stats_table, 0, sizeof(net_rx_debug_stats_table));
                cmd = DRV_IOR(NetRxDebugStatsTable_t, DRV_ENTRY_FLAG);
                CTC_ERROR_RETURN(DRV_IOCTL(lchip, mac_id, cmd, &net_rx_debug_stats_table));
                GetNetRxDebugStatsTable(A, fullDropCntSaturation_f, &net_rx_debug_stats_table, &value[0]);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_NETRX_NO_BUFFER, value[0]));
                value[0] = GetNetRxDebugStatsTable(V, overLenErrDropCntSaturation_f, &net_rx_debug_stats_table) +
                        GetNetRxDebugStatsTable(V, underLenErrDropCntSaturation_f, &net_rx_debug_stats_table);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_NETRX_LEN_ERROR, value[0]));
                value[0] = GetNetRxDebugStatsTable(V, pktErrDropCntSaturation_f, &net_rx_debug_stats_table) +
                        GetNetRxDebugStatsTable(V, pktWithErrorCntSaturation_f, &net_rx_debug_stats_table);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_NETRX_PKT_ERROR, value[0]));
                GetNetRxDebugStatsTable(A, frameErrDropCntSaturation_f, &net_rx_debug_stats_table, &value[0]);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_NETRX_FRAME_ERROR, value[0]));
                GetNetRxDebugStatsTable(A, validByteErrCntSaturation_f, &net_rx_debug_stats_table, &value[0]);
                CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_NETRX_VALIDBYTE_ERROR, value[0]));
            }
        }
        if(!(get_detail_en && (user_reason != CTC_DROP_TRAFFIC_MANAGER)))
        {
            sys_usw_queue_traverse_queue_node(lchip, lport, sys_tmm_diag_get_queu_io, p_data); 
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_ENQ_WRED_DROP, p_data[0]));
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_ENQ_TOTAL_DROP, p_data[1]));
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_ENQ_FWD_DROP, p_data[2]));
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_ENQ_NO_QUEUE_ENTRY, p_data[3]));
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_ENQ_PORT_NO_BUFF, p_data[4]));
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_ENQ_PORT_SC_NO_BUFF, p_data[5]));
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_ENQ_NO_RESRC, p_data[6]));
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_ENQ_SC_NO_BUFF, p_data[7]));
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_ENQ_SPAN_NO_BUFF, p_data[8]));
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_ENQ_TOTAL_NO_BUFF, p_data[9]));
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_ENQ_FWD_DROP_CFLEX_ISOLATE_BLOCK, p_data[10])); 
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_ENQ_FWD_DROP_CHAN_INVALID, p_data[11]));        
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_ENQ_FWD_DROP_TOTAL, p_data[12]));               
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_ENQ_FWD_DROP_PORT_ISOLATE_BLOCK, p_data[13])); 
            CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, lport, SYS_TMM_DISCARD_BSR_ENQ_FWD_DROP_RSV_CHAN_DROP, p_data[14]));  
        }
    }


get_system_stats:
    if(p_drop->lport != SYS_DIAG_DROP_COUNT_SYSTEM && get_detail_en)
    {
        return CTC_E_NONE;
    }
    sal_memset(value, 0, sizeof(value));
    for (index = 0; index < MCHIP_CAP(SYS_CAP_DP_MAX_NUM); index++)/* DP0 + DP1*/
    {
        sal_memset(&net_tx_debug_stats, 0, sizeof(net_tx_debug_stats));
        cmd = DRV_IOR(NetTxDebugStats_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, index, cmd, &net_tx_debug_stats));
        value[0] += GetNetTxDebugStats(V, minLenDropCnt_f, &net_tx_debug_stats);

        value[1] += GetNetTxDebugStats(V, rxNoBufCnt_f, &net_tx_debug_stats);

        value[2] = value[2] + GetNetTxDebugStats(V, rxNoEopDropCnt_f, &net_tx_debug_stats) +
                GetNetTxDebugStats(V, rxNoSopDropCnt_f, &net_tx_debug_stats);
        value[3] += GetNetTxDebugStats(V, txErrorCnt_f, &net_tx_debug_stats);
        value[47] += GetNetTxDebugStats(V, sopDiscardCnt_f, &net_tx_debug_stats);
        cmd = DRV_IOR(BufStoreDebugStats_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, index, cmd, &bsr_debug_stats));
        value[4] = value[4] + GetBufStoreDebugStats(V, metFifoMcastHighFullDropCnt_f, &bsr_debug_stats) + 
                GetBufStoreDebugStats(V, metFifoMcastLowFullDropCnt_f, &bsr_debug_stats) + 
                GetBufStoreDebugStats(V, metFifoUcastHighFullDropCnt_f, &bsr_debug_stats) + 
                GetBufStoreDebugStats(V, metFifoUcastLowFullDropCnt_f, &bsr_debug_stats);
        value[5] = value[5] + GetBufStoreDebugStats(V, toMetFifoCutDestIdDisCnt_f, &bsr_debug_stats) + 
                GetBufStoreDebugStats(V, toMetFifoCutExcpDestIdDisCnt_f, &bsr_debug_stats) + 
                GetBufStoreDebugStats(V, toMetFifoCutLogDestIdDisCnt_f, &bsr_debug_stats) + 
                GetBufStoreDebugStats(V, toMetFifoFwdDestIdDisCnt_f, &bsr_debug_stats) + 
                GetBufStoreDebugStats(V, toMetFifoFwdExcpDestIdDisCnt_f, &bsr_debug_stats) + 
                GetBufStoreDebugStats(V, toMetFifoFwdLogDestIdDisCnt_f, &bsr_debug_stats);
        value[6] += GetBufStoreDebugStats(V, sopPktLenErrorCnt_f, &bsr_debug_stats);

        cmd = DRV_IOR(BufRetrvDPDebugStats_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, index, cmd, &buf_retrv_dp_debug_stats));
        value[7] += GetBufRetrvDPDebugStats(V, frDeqMsgDiscardCnt_f, &buf_retrv_dp_debug_stats);
        value[8] += GetBufRetrvDPDebugStats(V, frQMgrLenErrorCnt_f, &buf_retrv_dp_debug_stats);
        value[9] = value[9] + GetBufRetrvDPDebugStats(V, toEpeHdrAdjErrorCnt_f, &buf_retrv_dp_debug_stats) + 
                GetBufRetrvDPDebugStats(V, toEpeScheduleErrorCnt_f, &buf_retrv_dp_debug_stats);
        
        cmd = DRV_IOR(EpeScheduleDebugStats_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, index, cmd, &epe_sch_debug_stats));
        value[10] += GetEpeScheduleDebugStats(V, minPktLenErrorCnt_f, &epe_sch_debug_stats);
        value[11] = value[11] + GetEpeScheduleDebugStats(V, elogAbortedIntf0PktCnt_f, &epe_sch_debug_stats) + 
                GetEpeScheduleDebugStats(V, elogAbortedIntf1PktCnt_f, &epe_sch_debug_stats) + 
                GetEpeScheduleDebugStats(V, elogDroppedIntf0PktCnt_f, &epe_sch_debug_stats) + 
                GetEpeScheduleDebugStats(V, elogDroppedIntf1PktCnt_f, &epe_sch_debug_stats);
        value[12] = value[12] + GetEpeScheduleDebugStats(V, txCpuMacTruncateDropPktCnt_f, &epe_sch_debug_stats) + 
                GetEpeScheduleDebugStats(V, txDmaTruncateDropPktCnt_f, &epe_sch_debug_stats) + 
                GetEpeScheduleDebugStats(V, txOamTruncateDropPktCnt_f, &epe_sch_debug_stats);
        value[13] = value[13] + GetEpeScheduleDebugStats(V, frBrDataErrorCnt_f, &epe_sch_debug_stats) + 
                GetEpeScheduleDebugStats(V, frEpeDataErrorCnt_f, &epe_sch_debug_stats);
        
        cmd = DRV_IOR(BufStoreStallDropCntSaturation_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, index, cmd, &bsr_stall_drop_cnt));
        value[14] += GetBufStoreStallDropCntSaturation(V, cpuMcastDropCnt_f, &bsr_stall_drop_cnt);
        value[15] += GetBufStoreStallDropCntSaturation(V, cpuUcastDropCnt_f, &bsr_stall_drop_cnt);
        value[16] += GetBufStoreStallDropCntSaturation(V, dmaMcastDropCnt_f, &bsr_stall_drop_cnt);
        value[17] += GetBufStoreStallDropCntSaturation(V, dmaUcastDropCnt_f, &bsr_stall_drop_cnt);
        value[18] += GetBufStoreStallDropCntSaturation(V, eLogMcastDropCnt_f, &bsr_stall_drop_cnt);
        value[19] += GetBufStoreStallDropCntSaturation(V, eLogUcastDropCnt_f, &bsr_stall_drop_cnt);
        value[20] += GetBufStoreStallDropCntSaturation(V, ipeHdrMcastDropCnt_f, &bsr_stall_drop_cnt);
        value[21] += GetBufStoreStallDropCntSaturation(V, ipeHdrUcastDropCnt_f, &bsr_stall_drop_cnt);
        value[22] += GetBufStoreStallDropCntSaturation(V, ipeMcastDropCnt_f, &bsr_stall_drop_cnt);
        value[23] += GetBufStoreStallDropCntSaturation(V, ipeUcastDropCnt_f, &bsr_stall_drop_cnt);
        value[24] += GetBufStoreStallDropCntSaturation(V, loopMcastDropCnt_f, &bsr_stall_drop_cnt);
        value[25] += GetBufStoreStallDropCntSaturation(V, loopUcastDropCnt_f, &bsr_stall_drop_cnt);
        value[26] += GetBufStoreStallDropCntSaturation(V, oamMcastDropCnt_f, &bsr_stall_drop_cnt);
        value[27] += GetBufStoreStallDropCntSaturation(V, oamUcastDropCnt_f, &bsr_stall_drop_cnt);

        cmd = DRV_IOR(NetRxDebugStats_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, index, cmd, &net_rx_debug_stats));
        value[28] += GetNetRxDebugStats(V, cpuMacRxDataErrCnt_f, &net_rx_debug_stats);
        value[29] += GetNetRxDebugStats(V, dmaRxDataErrCnt_f, &net_rx_debug_stats);
        value[30] += GetNetRxDebugStats(V, oamRxDataErrCnt_f, &net_rx_debug_stats);
        value[31] = value[31] + GetNetRxDebugStats(V, loop0RxDataErrCnt_f, &net_rx_debug_stats) +
                GetNetRxDebugStats(V, loop1RxDataErrCnt_f, &net_rx_debug_stats);
        value[32] = value[32] + GetNetRxDebugStats(V, txqm0RxErrorCnt_f, &net_rx_debug_stats) +
                GetNetRxDebugStats(V, txqm1RxErrorCnt_f, &net_rx_debug_stats) +
                GetNetRxDebugStats(V, txqm2RxErrorCnt_f, &net_rx_debug_stats) +
                GetNetRxDebugStats(V, txqm3RxErrorCnt_f, &net_rx_debug_stats);
        value[33] = value[33] + GetNetRxDebugStats(V, rxBpduDropCntSaturation0_f, &net_rx_debug_stats) +
                GetNetRxDebugStats(V, rxBpduDropCntSaturation1_f, &net_rx_debug_stats) +
                GetNetRxDebugStats(V, rxBpduDropCntSaturation2_f, &net_rx_debug_stats) +
                GetNetRxDebugStats(V, rxBpduDropCntSaturation3_f, &net_rx_debug_stats);
        value[34] += GetNetRxDebugStats(V, txErrCnt_f, &net_rx_debug_stats);
        value[35] += GetNetRxDebugStats(V, pauseFrameDiscardCnt_f, &net_rx_debug_stats);
        value[36] += GetNetRxDebugStats(V, midPrioDropCntSaturation3_f, &net_rx_debug_stats);
        value[37] += GetNetRxDebugStats(V, midPrioDropCntSaturation2_f, &net_rx_debug_stats);
        value[38] += GetNetRxDebugStats(V, midPrioDropCntSaturation1_f, &net_rx_debug_stats);
        value[39] += GetNetRxDebugStats(V, midPrioDropCntSaturation0_f, &net_rx_debug_stats);
        value[40] += GetNetRxDebugStats(V, highPrioDropCntSaturation3_f, &net_rx_debug_stats);
        value[41] += GetNetRxDebugStats(V, highPrioDropCntSaturation2_f, &net_rx_debug_stats);
        value[42] += GetNetRxDebugStats(V, highPrioDropCntSaturation1_f, &net_rx_debug_stats);
        value[43] += GetNetRxDebugStats(V, highPrioDropCntSaturation0_f, &net_rx_debug_stats);
        value[45] += GetNetRxDebugStats(V, cpuMacPktDropCnt_f, &net_rx_debug_stats);
        value[46] += GetNetRxDebugStats(V, netRxLengthChkFailedCnt_f, &net_rx_debug_stats);
    }
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETTX_MIN_LEN, value[0]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETTX_NO_BUFFER, value[1]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETTX_SOP_EOP, value[2]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETTX_TX_ERROR, value[3]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_BUFSTORE_FIFO_FULL, value[4]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_BUFSTORE_DROP_DESTID, value[5]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_BUFSTORE_OUT_SOP_PKT_LEN_ERR, value[6]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_BUFRETRV_FROM_DEQ_MSG_ERR, value[7]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_BUFRETRV_FROM_QMGR_LEN_ERR, value[8]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_BUFRETRV_OUT_DROP, value[9]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_EPE_MIN_PKT_LEN_ERR, value[10]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_EPE_ELOG_ABORTED_PKT, value[11]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_EPE_TRUNCATE_PKT, value[12]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_EPE_DATA_ERR, value[13]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_MC_FROM_CPU, value[14]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_UC_FROM_CPU, value[15]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_MC_FROM_DMA, value[16]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_UC_FROM_DMA, value[17]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_MC_FROM_ELOG, value[18]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_UC_FROM_ELOG, value[19]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_MC_FROM_IPE_CUT_THR, value[20]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_UC_FROM_IPE_CUT_THR, value[21]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_MC_FROM_IPE, value[22]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_UC_FROM_IPE, value[23]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_MC_FROM_ELOOP_MCAST, value[24]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_UC_FROM_ELOOP_UCAST, value[25]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_MC_FROM_OAM, value[26]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_UC_FROM_OAM, value[27]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_FROM_CPUMAC, value[28]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_FROM_DMA, value[29]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_FROM_OAM, value[30]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_FROM_LOOP, value[31]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_FROM_NETWORK, value[32]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_BPDU_ERROR, value[33]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_OUT_ERROR, value[34]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_PFC_ERROR, value[35]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_TXQM3_MIDPRIO_DROP, value[36]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_TXQM2_MIDPRIO_DROP, value[37]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_TXQM1_MIDPRIO_DROP, value[38]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_TXQM0_MIDPRIO_DROP, value[39]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_TXQM3_HIGHPRIO_DROP, value[40]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_TXQM2_HIGHPRIO_DROP, value[41]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_TXQM1_HIGHPRIO_DROP, value[42]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_TXQM0_HIGHPRIO_DROP, value[43]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_MTULEN_CHECK, value[45]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETRX_SOPBUF_FULL_DROP, value[46]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_NETTX_SOP, value[47]));

    cmd = DRV_IOR(OamFwdDebugStats_t, OamFwdDebugStats_asicHardDiscardCnt_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value[0]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_OAM_HW_ERROR, value[0]));

    cmd = DRV_IOR(OamFwdDebugStats_t, OamFwdDebugStats_exceptionDiscardCnt_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value[0]));
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_OAM_EXCEPTION, value[0]));
    
    cmd = DRV_IOR(EpeHdrProcDebugStats_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &epe_hdr_proc_debug_stats));
    value[0] = GetEpeHdrProcDebugStats(V, l2EditHardErrorCnt_f, &epe_hdr_proc_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_EPE_HW_L2_EDIT, value[0]));

    value[0] = GetEpeHdrProcDebugStats(V, l3EditHardErrorCnt_f, &epe_hdr_proc_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_EPE_HW_L3_EDIT, value[0]));

    value[0] = GetEpeHdrProcDebugStats(V, innerL2HardErrorCnt_f, &epe_hdr_proc_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_EPE_HW_INNER_L2, value[0]));

    value[0] = GetEpeHdrProcDebugStats(V, payloadHardErrorCnt_f, &epe_hdr_proc_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_EPE_HW_PAYLOAD, value[0]));

    value[0] = GetEpeHdrProcDebugStats(V, payloadDiscardCnt_f, &epe_hdr_proc_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_EPE_PAYLOAD, value[0]));
    
    value[0] = GetEpeHdrProcDebugStats(V, l2EditDiscardCnt_f, &epe_hdr_proc_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_EPE_L2_EDIT, value[0]));

    value[0] = GetEpeHdrProcDebugStats(V, l3EditDiscardCnt_f, &epe_hdr_proc_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_EPE_L3_EDIT, value[0]));

    value[0] = GetEpeHdrProcDebugStats(V, innerL2DiscardCnt_f, &epe_hdr_proc_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_EPE_INNER_L2, value[0]));

    cmd = DRV_IOR(QMgrErmDebugStats_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &qmgr_erm_debug_stats));
    value[0] = GetQMgrErmDebugStats(V, spanAndResrcCheckDropCnt_f, &qmgr_erm_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_ERM_CHECK_FAIL, value[0]));
    value[0] = GetQMgrErmDebugStats(V, resrcChkCriticalDropCnt_f, &qmgr_erm_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_ERM_CRIT_CHECK_FAIL, value[0]));
    value[0] = GetQMgrErmDebugStats(V, resrcChkTotalDropCnt_f, &qmgr_erm_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_ERM_TOTAL_CHECK_FAIL, value[0]));
    value[0] = GetQMgrErmDebugStats(V, resrcChkScDropCnt_f, &qmgr_erm_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_ERM_SC_CHECK_FAIL, value[0]));
    value[0] = GetQMgrErmDebugStats(V, resrcChkPortScDropCnt_f, &qmgr_erm_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_ERM_PORTSC_CHECK_FAIL, value[0]));
    value[0] = GetQMgrErmDebugStats(V, resrcChkPortDropCnt_f, &qmgr_erm_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_ERM_PORT_CHECK_FAIL, value[0]));
    value[0] = GetQMgrErmDebugStats(V, resrcChkQueueDropCnt_f, &qmgr_erm_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_ERM_QUEUE_CHECK_FAIL, value[0]));
    value[0] = GetQMgrErmDebugStats(V, resrcChkAqmQueueDropCnt_f, &qmgr_erm_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_ERM_AQMQUEUE_CHECK_FAIL, value[0]));
    value[0] = GetQMgrErmDebugStats(V, resrcChkC2cDropCnt_f, &qmgr_erm_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_ERM_C2C_CHECK_FAIL, value[0]));
    value[0] = GetQMgrErmDebugStats(V, freePtrFifoEmptyDropCnt_f, &qmgr_erm_debug_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_ERM_NO_FREEPTR, value[0]));

    cmd = DRV_IOR(QMgrQWriteDebugStats_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &qmgr_qwrite_stats));
    value[0] = GetQMgrQWriteDebugStats(V, cFlexIsolateBlockDiscardCnt_f, &qmgr_qwrite_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_QWRITE_CFLEX_ISOLATE_BLOCK, value[0]));
    value[0] = GetQMgrQWriteDebugStats(V, portIsolateBlockDiscardCnt_f, &qmgr_qwrite_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_QWRITE_PORT_ISOLATE_BLOCK, value[0]));
    value[0] = GetQMgrQWriteDebugStats(V, rsvChanDropCnt_f, &qmgr_qwrite_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_QWRITE_CHAN, value[0]));
    value[0] = GetQMgrQWriteDebugStats(V, fromFabricToIloopChannelDropCnt_f, &qmgr_qwrite_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_QWRITE_FABRIC_TO_ILOOP, value[0]));
    value[0] = GetQMgrQWriteDebugStats(V, frMetDiscardDropCnt_f, &qmgr_qwrite_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_QWRITE_DROP_FROM_MET, value[0]));

    cmd = DRV_IOR(MetFifoProcDebugStats_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &met_proc_stats));
    value[0] = GetMetFifoProcDebugStats(V, ucastHiLogSilentDropCnt_f, &met_proc_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_UCHI_COVER_LOG, value[0]));
    value[0] = GetMetFifoProcDebugStats(V, ucastLoLogSilentDropCnt_f, &met_proc_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_UCLO_COVER_LOG, value[0]));
    value[0] = GetMetFifoProcDebugStats(V, mcastHiLogSilentDropCnt_f, &met_proc_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_MCHI_COVER_LOG, value[0]));
    value[0] = GetMetFifoProcDebugStats(V, mcastLoLogSilentDropCnt_f, &met_proc_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_MCLO_COVER_LOG, value[0]));
    value[0] = GetMetFifoProcDebugStats(V, ucastHiLogDropFreeCnt_f, &met_proc_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_UCHI_IS_LOG, value[0]));
    value[0] = GetMetFifoProcDebugStats(V, ucastLoLogDropFreeCnt_f, &met_proc_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_UCLO_IS_LOG, value[0]));
    value[0] = GetMetFifoProcDebugStats(V, mcastHiLogDropFreeCnt_f, &met_proc_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_MCHI_IS_LOG, value[0]));
    value[0] = GetMetFifoProcDebugStats(V, mcastLoLogDropFreeCnt_f, &met_proc_stats);
    CTC_ERROR_RETURN(sys_usw_diag_drop_hash_update_count(lchip, SYS_DIAG_DROP_COUNT_SYSTEM, SYS_TMM_DISCARD_BSR_METFIFO_MCLO_IS_LOG, value[0]));

    return CTC_E_NONE;
}


#define ______DIAG_MCHIP_API______

int32
sys_tmm_diag_get_pkt_trace(uint8 lchip, void* p_value)
{

    ctc_diag_pkt_trace_result_t* p_rslt = (ctc_diag_pkt_trace_result_t*)p_value;

    CTC_PTR_VALID_CHECK(p_rslt);
    p_usw_diag_master[lchip]->cur_discard_type_map = 0;
	p_usw_diag_master[lchip]->cur_exception_map = 0;
    CTC_ERROR_RETURN(_sys_tmm_diag_get_pkt_trace_pos_ipe(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_get_pkt_trace_pos_tm(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_get_pkt_trace_pos_epe(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_get_pkt_trace_pos_oam(lchip, p_rslt));
    CTC_ERROR_RETURN(_sys_tmm_diag_get_pkt_trace_pos_sc_oam(lchip, p_rslt));

    return CTC_E_NONE;
}

int32
sys_tmm_diag_get_drop_info(uint8 lchip, void* p_value)
{
    ctc_diag_drop_t* p_drop = (ctc_diag_drop_t*)p_value;
    CTC_PTR_VALID_CHECK(p_drop);
    CTC_ERROR_RETURN(_sys_tmm_diag_get_drop_info(lchip, p_drop));
    return CTC_E_NONE;
}

int32
sys_tmm_diag_get_queu_io(uint8 lchip, sys_traverse_t* data)
{
    uint32 cmd = 0;
    uint32* p_data = (uint32*)data->data;
    uint32 queue_id = data->value1; 
    ds_t ds;
    //QMgrErmResrcDropCntSaturation   
    cmd = DRV_IOR(QMgrErmResrcDropCntSaturation_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, queue_id, cmd, &ds));
    p_data[0] += GetQMgrErmResrcDropCntSaturation(V, dropCntAmQueueDropRd_f, &ds);
    p_data[1] += GetQMgrErmResrcDropCntSaturation(V, dropCntFinalDropRd_f, &ds);
    p_data[2] += GetQMgrErmResrcDropCntSaturation(V, dropCntForwardDropRd_f, &ds);
    p_data[3] += GetQMgrErmResrcDropCntSaturation(V, dropCntFreePtrEmptyDropRd_f, &ds);
    p_data[4] = p_data[4] + GetQMgrErmResrcDropCntSaturation(V, dropCntPortDropRd_f, &ds) +
                GetQMgrErmResrcDropCntSaturation(V, dropCntQueueDropRd_f, &ds);
    p_data[5] += GetQMgrErmResrcDropCntSaturation(V, dropCntPortScDropRd_f, &ds);
    p_data[6] += GetQMgrErmResrcDropCntSaturation(V, dropCntResrcCheckDropRd_f, &ds);
    p_data[7] += GetQMgrErmResrcDropCntSaturation(V, dropCntScDropRd_f, &ds);
    p_data[8] += GetQMgrErmResrcDropCntSaturation(V, dropCntSpanOnDropRd_f, &ds);
    p_data[9] += GetQMgrErmResrcDropCntSaturation(V, dropCntTotalDropRd_f, &ds);

    //QMgrEnqForwardDropCntSaturation
    cmd = DRV_IOR(QMgrEnqForwardDropCntSaturation_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, queue_id, cmd, &ds));
    p_data[10] += GetQMgrEnqForwardDropCntSaturation(V, dropCntCFlexIsolateBlockRd_f, &ds);
    p_data[11] += GetQMgrEnqForwardDropCntSaturation(V, dropCntChanIdInvalidRd_f, &ds);
    p_data[12] += GetQMgrEnqForwardDropCntSaturation(V, dropCntForwardDropValidRd_f, &ds);
    p_data[13] += GetQMgrEnqForwardDropCntSaturation(V, dropCntPortIsolateBlockRd_f, &ds);
    p_data[14] += GetQMgrEnqForwardDropCntSaturation(V, dropCntRsvChanDropValidRd_f, &ds);
    return CTC_E_NONE;
}

int32
sys_tmm_diag_set_dbg_pkt(uint8 lchip, void* p_value)
{
    uint32 cmd = 0;
    uint32 loop = 0;
    uint32 tmp_data = 0;
    uint32 tmp_mask = 0;
    hw_mac_addr_t   hw_mac      = {0};
    ipv6_addr_t     hw_ip6 = {0};
    ctc_field_key_t*  field = NULL;
    ctc_diag_pkt_trace_t* p_trace = (ctc_diag_pkt_trace_t*)p_value;
    IpeUserIdFlowCam_m ds_flow_cam;
    ParserResult_m parser_result;
    ParserResult_m parser_result_mask;

    CTC_PTR_VALID_CHECK(p_trace);
    sal_memset(&ds_flow_cam, 0, sizeof(IpeUserIdFlowCam_m));
    sal_memset(&parser_result, 0, sizeof(ParserResult_m));
    sal_memset(&parser_result_mask, 0, sizeof(ParserResult_m));
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_clear_rslt(lchip, p_trace->watch_point));
    while (loop < p_trace->pkt.network.count)
    {
        field = &(p_trace->pkt.network.field[loop]);
        loop++;
        switch (field->type)
        {
            case CTC_FIELD_KEY_L2_TYPE:
                SetParserResult(V, layer2Type_f, &parser_result, field->data);
                SetParserResult(V, layer2Type_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_L3_TYPE:
                SetParserResult(V, layer3Type_f, &parser_result, field->data);
                SetParserResult(V, layer3Type_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_L4_TYPE:
                SetParserResult(V, layer4Type_f, &parser_result, sys_usw_l4_type_map(lchip, field->data, TRUE));
                SetParserResult(V, layer4Type_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_L4_USER_TYPE:
                SetParserResult(V, layer4UserType_f, &parser_result, sys_usw_l4_user_type_map(lchip, field->data, 1));
                SetParserResult(V, layer4UserType_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_ETHER_TYPE:
                SetParserResult(V, etherType_f, &parser_result, field->data);
                SetParserResult(V, etherType_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_MAC_DA:
                CTC_PTR_VALID_CHECK(field->ext_data);
                CTC_PTR_VALID_CHECK(field->ext_mask);
                SYS_USW_SET_HW_MAC(hw_mac, (uint8*)field->ext_data);
                SetParserResult(A, macDa_f, &parser_result, hw_mac);
                SYS_USW_SET_HW_MAC(hw_mac, (uint8*)field->ext_mask);
                SetParserResult(A, macDa_f, &parser_result_mask, hw_mac);
                break;
            case CTC_FIELD_KEY_MAC_SA:
                CTC_PTR_VALID_CHECK(field->ext_data);
                CTC_PTR_VALID_CHECK(field->ext_mask);
                SYS_USW_SET_HW_MAC(hw_mac, (uint8*)field->ext_data);
                SetParserResult(A, macSa_f, &parser_result, hw_mac);
                SYS_USW_SET_HW_MAC(hw_mac, (uint8*)field->ext_mask);
                SetParserResult(A, macSa_f, &parser_result_mask, hw_mac);
                break;
            case CTC_FIELD_KEY_SVLAN_ID:
                SetParserResult(V, svlanId_f, &parser_result, field->data);
                SetParserResult(V, svlanId_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_CVLAN_ID:
                SetParserResult(V, cvlanId_f, &parser_result, field->data);
                SetParserResult(V, cvlanId_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_VLAN_NUM:
                SetParserResult(V, vlanNum_f, &parser_result, field->data);
                SetParserResult(V, vlanNum_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_IP_SA:
                SetParserResult(V, uL3Source_gIpv4_ipSa_f, &parser_result, field->data);
                SetParserResult(V, uL3Source_gIpv4_ipSa_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_IP_DA:
                SetParserResult(V, uL3Dest_gIpv4_ipDa_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gIpv4_ipDa_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_IPV6_SA:
                CTC_PTR_VALID_CHECK(field->ext_data);
                CTC_PTR_VALID_CHECK(field->ext_mask);
                SYS_USW_REVERT_IP6(hw_ip6, (uint32*)field->ext_data);
                SetParserResult(A, uL3Source_gIpv6_ipSa_f, &parser_result, hw_ip6);
                SYS_USW_REVERT_IP6(hw_ip6, (uint32*)field->ext_mask);
                SetParserResult(A, uL3Source_gIpv6_ipSa_f, &parser_result_mask, hw_ip6);
                break;
            case CTC_FIELD_KEY_IPV6_DA:
                CTC_PTR_VALID_CHECK(field->ext_data);
                CTC_PTR_VALID_CHECK(field->ext_mask);
                SYS_USW_REVERT_IP6(hw_ip6, (uint32*)field->ext_data);
                SetParserResult(A, uL3Dest_gIpv6_ipDa_f, &parser_result, hw_ip6);
                SYS_USW_REVERT_IP6(hw_ip6, (uint32*)field->ext_mask);
                SetParserResult(A, uL3Dest_gIpv6_ipDa_f, &parser_result_mask, hw_ip6);
                break;
            case CTC_FIELD_KEY_IPV6_FLOW_LABEL:
                SetParserResult(V, ipv6FlowLabel_f, &parser_result, field->data);
                SetParserResult(V, ipv6FlowLabel_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_IP_PROTOCOL:
                SetParserResult(V, layer3HeaderProtocol_f, &parser_result, field->data);
                SetParserResult(V, layer3HeaderProtocol_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_IP_TTL:
                SetParserResult(V, ttl_f, &parser_result, field->data);
                SetParserResult(V, ttl_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_ARP_OP_CODE:
                SetParserResult(V, uL3Dest_gArp_arpOpCode_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gArp_arpOpCode_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_ARP_PROTOCOL_TYPE:
                SetParserResult(V, uL3Source_gArp_protocolType_f, &parser_result, field->data);
                SetParserResult(V, uL3Source_gArp_protocolType_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_ARP_SENDER_IP:
                SetParserResult(V, uL3Source_gArp_senderIp_f, &parser_result, field->data);
                SetParserResult(V, uL3Source_gArp_senderIp_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_ARP_TARGET_IP:
                SetParserResult(V, uL3Dest_gArp_targetIp_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gArp_targetIp_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_SENDER_MAC:
                CTC_PTR_VALID_CHECK(field->ext_data);
                CTC_PTR_VALID_CHECK(field->ext_mask);
                SYS_USW_SET_HW_MAC(hw_mac, (uint8*)field->ext_data);
                SetParserResult(A, uL3Source_gArp_senderMac_f, &parser_result, hw_mac);
                SYS_USW_SET_HW_MAC(hw_mac, (uint8*)field->ext_mask);
                SetParserResult(A, uL3Source_gArp_senderMac_f, &parser_result_mask, hw_mac);
                break;
            case CTC_FIELD_KEY_TARGET_MAC:
                CTC_PTR_VALID_CHECK(field->ext_data);
                CTC_PTR_VALID_CHECK(field->ext_mask);
                SYS_USW_SET_HW_MAC(hw_mac, (uint8*)field->ext_data);
                SetParserResult(A, uL3Dest_gArp_targetMac_f, &parser_result, hw_mac);
                SYS_USW_SET_HW_MAC(hw_mac, (uint8*)field->ext_mask);
                SetParserResult(A, uL3Dest_gArp_targetMac_f, &parser_result_mask, hw_mac);
                break;
            case CTC_FIELD_KEY_ETHER_OAM_LEVEL:
                SetParserResult(V, uL3Dest_gEtherOam_etherOamLevel_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gEtherOam_etherOamLevel_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_ETHER_OAM_OP_CODE:
                SetParserResult(V, uL3Dest_gEtherOam_etherOamOpCode_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gEtherOam_etherOamOpCode_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_ETHER_OAM_VERSION:
                SetParserResult(V, uL3Dest_gEtherOam_etherOamVersion_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gEtherOam_etherOamVersion_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_FCOE_DST_FCID:
                SetParserResult(V, uL3Dest_gFcoe_fcoeDid_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gFcoe_fcoeDid_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_FCOE_SRC_FCID:
                SetParserResult(V, uL3Source_gFcoe_fcoeSid_f, &parser_result, field->data);
                SetParserResult(V, uL3Source_gFcoe_fcoeSid_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_LABEL_NUM:
                SetParserResult(V, uL3Tos_gMpls_labelNum_f, &parser_result, field->data);
                SetParserResult(V, uL3Tos_gMpls_labelNum_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_MPLS_LABEL0:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result, ((field->data&0xFFFFF) << 12)|(tmp_data&0xFFF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result_mask, ((field->mask&0xFFFFF) << 12)|(tmp_mask&0xFFF));
                break;
            case CTC_FIELD_KEY_MPLS_EXP0:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result, ((field->data& 0x7) << 9)|(tmp_data&0xFFFFF1FF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result_mask, ((field->mask & 0x7) << 9)|(tmp_mask&0xFFFFF1FF));
                break;
            case CTC_FIELD_KEY_MPLS_SBIT0:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result, ((field->data & 0x1) << 8)|(tmp_data&0xFFFFFEFF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result_mask, ((field->mask & 0x1) << 8)|(tmp_mask&0xFFFFFEFF));
                break;
            case CTC_FIELD_KEY_MPLS_TTL0:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result, (field->data &0xFF)|(tmp_data&0xFFFFFF00));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel0_f, &parser_result_mask, (field->mask &0xFF)|(tmp_mask&0xFFFFFF00));
                break;
            case CTC_FIELD_KEY_MPLS_LABEL1:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result, ((field->data&0xFFFFF) << 12) | (tmp_data&0xFFF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result_mask, ((field->mask&0xFFFFF) << 12) | (tmp_mask&0xFFF));
                break;
            case CTC_FIELD_KEY_MPLS_EXP1:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result, ((field->data& 0x7) << 9)  | (tmp_data&0xFFFFF1FF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result_mask, ((field->mask & 0x7) << 9) | (tmp_mask&0xFFFFF1FF));
                break;
            case CTC_FIELD_KEY_MPLS_SBIT1:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result, ((field->data & 0x1) << 8)| (tmp_data&0xFFFFFEFF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result_mask, ((field->mask & 0x1) << 8) | (tmp_mask&0xFFFFFEFF));
                break;
            case CTC_FIELD_KEY_MPLS_TTL1:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result, (field->data &0xFF) | (tmp_data&0xFFFFFF00));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel1_f, &parser_result_mask, (field->mask &0xFF) | (tmp_mask&0xFFFFFF00));
                break;
            case CTC_FIELD_KEY_MPLS_LABEL2:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result, ((field->data&0xFFFFF) << 12) | (tmp_data&0xFFF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result_mask, ((field->mask&0xFFFFF) << 12) | (tmp_mask&0xFFF));
                break;
            case CTC_FIELD_KEY_MPLS_EXP2:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result, ((field->data& 0x7) << 9)  | (tmp_data&0xFFFFF1FF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result_mask, ((field->mask & 0x7) << 9) | (tmp_mask&0xFFFFF1FF));
                break;
            case CTC_FIELD_KEY_MPLS_SBIT2:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result, ((field->data & 0x1) << 8)| (tmp_data&0xFFFFFEFF));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result_mask, ((field->mask & 0x1) << 8) | (tmp_mask&0xFFFFFEFF));
                break;
            case CTC_FIELD_KEY_MPLS_TTL2:
                tmp_data =  GetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result);
                tmp_mask = GetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result_mask);
                SetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result, (field->data &0xFF) | (tmp_data&0xFFFFFF00));
                SetParserResult(V, uL3Dest_gMpls_mplsLabel2_f, &parser_result_mask, (field->mask &0xFF) | (tmp_mask&0xFFFFFF00));
                break;
            case CTC_FIELD_KEY_SLOW_PROTOCOL_CODE:
                SetParserResult(V, uL3Dest_gSlowProto_slowProtocolCode_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gSlowProto_slowProtocolCode_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_SLOW_PROTOCOL_FLAGS:
                SetParserResult(V, uL3Dest_gSlowProto_slowProtocolFlags_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gSlowProto_slowProtocolFlags_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_SLOW_PROTOCOL_SUB_TYPE:
                SetParserResult(V, uL3Dest_gSlowProto_slowProtocolSubType_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gSlowProto_slowProtocolSubType_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_INGRESS_NICKNAME:
                SetParserResult(V, uL3Source_gTrill_ingressNickname_f, &parser_result, field->data);
                SetParserResult(V, uL3Source_gTrill_ingressNickname_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_EGRESS_NICKNAME:
                SetParserResult(V, uL3Dest_gTrill_egressNickname_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gTrill_egressNickname_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_TRILL_INNER_VLANID:
                SetParserResult(V, uL3Dest_gTrill_trillInnerVlanId_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gTrill_trillInnerVlanId_f, &parser_result_mask, field->mask);
                SetParserResult(V, uL3Dest_gTrill_trillInnerVlanValid_f, &parser_result, 1);
                SetParserResult(V, uL3Dest_gTrill_trillInnerVlanValid_f, &parser_result_mask, 1);
                break;
            case CTC_FIELD_KEY_TRILL_VERSION:
                SetParserResult(V, uL3Dest_gTrill_trillVersion_f, &parser_result, field->data);
                SetParserResult(V, uL3Dest_gTrill_trillVersion_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_L4_DST_PORT:
                SetParserResult(V, uL4Dest_gPort_l4DestPort_f, &parser_result, field->data);
                SetParserResult(V, uL4Dest_gPort_l4DestPort_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_L4_SRC_PORT:
                SetParserResult(V, uL4Source_gPort_l4SourcePort_f, &parser_result, field->data);
                SetParserResult(V, uL4Source_gPort_l4SourcePort_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_TCP_ECN:
                SetParserResult(V, uL4UserData_gTcp_tcpEcn_f, &parser_result, field->data);
                SetParserResult(V, uL4UserData_gTcp_tcpEcn_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_TCP_FLAGS:
                SetParserResult(V, uL4UserData_gTcp_tcpFlags_f, &parser_result, field->data);
                SetParserResult(V, uL4UserData_gTcp_tcpFlags_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_VN_ID:
                SetParserResult(V, uL4UserData_gVxlan_vxlanVni_f, &parser_result, field->data);
                SetParserResult(V, uL4UserData_gVxlan_vxlanVni_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_VXLAN_FLAGS:
                SetParserResult(V, uL4UserData_gVxlan_vxlanFlags_f, &parser_result, field->data);
                SetParserResult(V, uL4UserData_gVxlan_vxlanFlags_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_VXLAN_RSV1:
                SetParserResult(V, uL4UserData_gVxlan_vxlanReserved1_f, &parser_result, field->data);
                SetParserResult(V, uL4UserData_gVxlan_vxlanReserved1_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_VXLAN_RSV2:
                SetParserResult(V, uL4UserData_gVxlan_vxlanReserved2_f, &parser_result, field->data);
                SetParserResult(V, uL4UserData_gVxlan_vxlanReserved2_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_GRE_KEY:
                SetParserResult(V, uL4UserData_gGre_greKey_f, &parser_result, field->data);
                SetParserResult(V, uL4UserData_gGre_greKey_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_GRE_FLAGS:
                SetParserResult(V, uL4Source_gGre_greFlags_f, &parser_result, field->data);
                SetParserResult(V, uL4Source_gGre_greFlags_f, &parser_result_mask, field->mask);
                break;
            case CTC_FIELD_KEY_GRE_PROTOCOL_TYPE:
                SetParserResult(V, uL4Dest_gGre_greProtocolType_f, &parser_result, field->data);
                SetParserResult(V, uL4Dest_gGre_greProtocolType_f, &parser_result_mask, field->mask);
                break;
            default:
                return CTC_E_NOT_SUPPORT;
        }
    }
    cmd = DRV_IOW(IpeUserIdFlowCam_t, DRV_ENTRY_FLAG);
    SetIpeUserIdFlowCam(A, g_0_data_f, &ds_flow_cam, &parser_result);
    SetIpeUserIdFlowCam(A, g_1_data_f, &ds_flow_cam, &parser_result_mask);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ds_flow_cam));
    return CTC_E_NONE;
}

int32
sys_tmm_diag_set_dbg_session(uint8 lchip, void* p_value)
{
    uint32 value = 0;
    uint32 cmd = 0;
    uint32 dest_map = 0;
    uint32 watch_point = 0;
    uint8 io_valid1 = 0;
    uint8 io_valid2 = 0;
    uint8 dpid = 2;
    ctc_diag_pkt_trace_t* p_trace = (ctc_diag_pkt_trace_t*)p_value;
    ctc_diag_trace_watch_key_t* watch_key = NULL;
    IpeUserIdFlowCam_m ds_flow_cam;
    BufStoreDebugCam_m ds_buff_store_cam;
    MetFifoDebugCam_m ds_met_fifo_cam;
    EpeHdrAdjustDebugCam_m ds_epe_dbg_cam;
    ds_t ds;

    CTC_PTR_VALID_CHECK(p_trace);
    sal_memset(&ds_flow_cam, 0, sizeof(IpeUserIdFlowCam_m));
    sal_memset(&ds_buff_store_cam, 0, sizeof(BufStoreDebugCam_m));
    sal_memset(&ds_met_fifo_cam, 0, sizeof(MetFifoDebugCam_m));
    sal_memset(&ds_epe_dbg_cam, 0, sizeof(EpeHdrAdjustDebugCam_m));
    sal_memset(&ds, 0, sizeof(ds_t));

    /*MUST read first, because sys_xxx_diag_set_dbg_pkt have config this table*/
    cmd = DRV_IOR(IpeUserIdFlowCam_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ds_flow_cam));
    watch_point = p_trace->watch_point;
    watch_key = &p_trace->watch_key;
    CTC_ERROR_RETURN(_sys_tmm_diag_pkt_trace_clear_rslt(lchip, watch_point));

    /* MetFif select isDbgPkt */
    value = 1;
    cmd = DRV_IOW(MetFifoDebugCtl_t, MetFifoDebugCtl_gSrcChanType_0_debugPathSel_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
    cmd =DRV_IOW(MetFifoDebugCtl_t, MetFifoDebugCtl_gSrcChanType_1_debugPathSel_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
    cmd = DRV_IOW(MetFifoDebugCtl_t, MetFifoDebugCtl_gSrcChanType_2_debugPathSel_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
    cmd = DRV_IOW(MetFifoDebugCtl_t, MetFifoDebugCtl_gSrcChanType_3_debugPathSel_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
    cmd = DRV_IOW(MetFifoDebugCtl_t, MetFifoDebugCtl_gSrcChanType_4_debugPathSel_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
    cmd = DRV_IOW(MetFifoDebugCtl_t, MetFifoDebugCtl_gSrcChanType_5_debugPathSel_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
    cmd = DRV_IOW(MetFifoDebugCtl_t, MetFifoDebugCtl_gSrcChanType_6_debugPathSel_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
    cmd = DRV_IOW(MetFifoDebugCtl_t, MetFifoDebugCtl_gSrcChanType_7_debugPathSel_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));

    value = (watch_point == CTC_DIAG_TRACE_POINT_IPE_SCL) ? 0 : 1;
    cmd = DRV_IOW(IpeUserIdFlowLoopCam_t, IpeUserIdFlowLoopCam_isDebuggedPktMask_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
    cmd = DRV_IOW(IpeUserIdFlowCtl_t, IpeUserIdFlowCtl_debugMode_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));

    switch (watch_point)
    {
        case CTC_DIAG_TRACE_POINT_IPE_SCL:
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_SRC_LPORT))
            {
                SetIpeUserIdFlowCam(V, g_0_localPhyPort_f, &ds_flow_cam, watch_key->src_lport);
                SetIpeUserIdFlowCam(V, g_1_localPhyPort_f, &ds_flow_cam, 0xFF);
            }
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_CHANNEL))
            {
                SetIpeUserIdFlowCam(V, g_0_channelId0_f, &ds_flow_cam, watch_key->channel);
                SetIpeUserIdFlowCam(V, g_0_channelId1_f, &ds_flow_cam, 0xFF);
                SetIpeUserIdFlowCam(V, g_0_channelId2_f, &ds_flow_cam, 0xFF);
                SetIpeUserIdFlowCam(V, g_0_channelId3_f, &ds_flow_cam, 0xFF);
                SetIpeUserIdFlowCam(V, g_1_channelId0_f, &ds_flow_cam, 0xFF);
                SetIpeUserIdFlowCam(V, g_1_channelId1_f, &ds_flow_cam, 0xFF);
                SetIpeUserIdFlowCam(V, g_1_channelId2_f, &ds_flow_cam, 0xFF);
                SetIpeUserIdFlowCam(V, g_1_channelId3_f, &ds_flow_cam, 0xFF);
            }
            if (p_trace->mode == CTC_DIAG_TRACE_MODE_USER)
            {
                SetBufStoreDebugCam(V, g_0_sourcePort_f, &ds_buff_store_cam, (SYS_MAP_CTC_GPORT_TO_DRV_GPORT(p_trace->pkt.user.src_port)));
                SetBufStoreDebugCam(V, g_1_sourcePort_f, &ds_buff_store_cam, 0xFFFF);
            }
            value = 1;
            cmd = DRV_IOW(DbgOamHdrAdj_t, DbgOamHdrAdj_debug1stPkt_f);
            CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
            cmd = DRV_IOW(DbgOamHdrAdj_t, DbgOamHdrAdj_debugSessionEn_f);
            CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
            cmd = DRV_IOW(DbgSCLEngineDecoderSclInputInfo_t, DbgSCLEngineDecoderSclInputInfo_debugSessionEn_f);
            CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
            goto install_ipe;
        case CTC_DIAG_TRACE_POINT_TM_BS:
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_CHANNEL))
            {
                SetBufStoreDebugCam(V, g_0_channelId_f, &ds_buff_store_cam, watch_key->channel);
                SetBufStoreDebugCam(V, g_1_channelId_f, &ds_buff_store_cam, 0xFF);
                dpid = (watch_key->channel >= MCHIP_CAP(SYS_CAP_PER_DP_CHANNEL_NUM))? 1:0;

                SetEpeHdrAdjustDebugCam(V, g_0_channelId_f, &ds_epe_dbg_cam, watch_key->channel);
                SetEpeHdrAdjustDebugCam(V, g_1_channelId_f, &ds_epe_dbg_cam, 0xFF);
            }
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_SRC_GPORT))
            {               
                SetBufStoreDebugCam(V, g_0_sourcePort_f, &ds_buff_store_cam, SYS_MAP_CTC_GPORT_TO_DRV_GPORT(watch_key->src_gport));
                SetBufStoreDebugCam(V, g_1_sourcePort_f, &ds_buff_store_cam, 0xFFFF);

                SetEpeHdrAdjustDebugCam(V, g_0_sourcePort_f, &ds_epe_dbg_cam, SYS_MAP_CTC_GPORT_TO_DRV_GPORT(watch_key->src_gport));
                SetEpeHdrAdjustDebugCam(V, g_1_sourcePort_f, &ds_epe_dbg_cam, 0xFFFF);
            }
            else if (p_trace->mode == CTC_DIAG_TRACE_MODE_USER)
            {
                SetBufStoreDebugCam(V, g_0_sourcePort_f, &ds_buff_store_cam, SYS_MAP_CTC_GPORT_TO_DRV_GPORT(p_trace->pkt.user.src_port));
                SetBufStoreDebugCam(V, g_1_sourcePort_f, &ds_buff_store_cam, 0xFFFF);
            }

            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_SRC_LPORT))
            {
                SetBufStoreDebugCam(V, g_0_localPhyPort_f, &ds_buff_store_cam, watch_key->src_lport);
                SetBufStoreDebugCam(V, g_1_localPhyPort_f, &ds_buff_store_cam, 0xFF);

                SetEpeHdrAdjustDebugCam(V, g_0_localPhyPort_f, &ds_epe_dbg_cam, watch_key->src_lport);
                SetEpeHdrAdjustDebugCam(V, g_1_localPhyPort_f, &ds_epe_dbg_cam, 0xFF);
            }
            SetBufStoreDebugCam(V, g_0_isDebuggedPkt_f, &ds_buff_store_cam, 1);
            SetBufStoreDebugCam(V, g_1_isDebuggedPkt_f, &ds_buff_store_cam, 0x1);
            goto install_bsr;
        case CTC_DIAG_TRACE_POINT_TM_MET:
            value = 0;
            cmd = DRV_IOW(MetFifoCtl_t, MetFifoCtl_debugLookupEn_f);
            CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_DST_GPORT))
            {
                dest_map = SYS_ENCODE_DESTMAP(CTC_MAP_GPORT_TO_GCHIP(watch_key->dst_gport),
                                              CTC_MAP_GPORT_TO_LPORT(watch_key->dst_gport));
                dest_map |= (1 << 18);
                SetMetFifoDebugCam(V, g_0_destMap_f, &ds_met_fifo_cam, dest_map & 0x7FFFF);
                SetMetFifoDebugCam(V, g_1_destMap_f, &ds_met_fifo_cam, 0x7FFFF);

                SetEpeHdrAdjustDebugCam(V, g_0_destMap_f, &ds_epe_dbg_cam, dest_map & 0x7FFFF);
                SetEpeHdrAdjustDebugCam(V, g_1_destMap_f, &ds_epe_dbg_cam, 0x7FFFF);
            }
            goto install_met;
        case CTC_DIAG_TRACE_POINT_EPE_ADJ:
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_CHANNEL))
            {
                SetEpeHdrAdjustDebugCam(V, g_0_channelId_f, &ds_epe_dbg_cam, watch_key->channel);
                SetEpeHdrAdjustDebugCam(V, g_1_channelId_f, &ds_epe_dbg_cam, 0xFF);
            }
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_SRC_LPORT))
            {
                SetEpeHdrAdjustDebugCam(V, g_0_localPhyPort_f, &ds_epe_dbg_cam, watch_key->src_lport);
                SetEpeHdrAdjustDebugCam(V, g_1_localPhyPort_f, &ds_epe_dbg_cam, 0xFF);
            }
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_SRC_GPORT))
            {
                SetEpeHdrAdjustDebugCam(V, g_0_sourcePort_f, &ds_epe_dbg_cam, SYS_MAP_CTC_GPORT_TO_DRV_GPORT(watch_key->src_gport));
                SetEpeHdrAdjustDebugCam(V, g_1_sourcePort_f, &ds_epe_dbg_cam, 0xFFFF);
            }
            else if (p_trace->mode == CTC_DIAG_TRACE_MODE_USER)
            {
                SetBufStoreDebugCam(V, g_0_sourcePort_f, &ds_buff_store_cam, SYS_MAP_CTC_GPORT_TO_DRV_GPORT(p_trace->pkt.user.src_port));
                SetBufStoreDebugCam(V, g_1_sourcePort_f, &ds_buff_store_cam, 0xFFFF);
            }
            goto install_epe;
        case CTC_DIAG_TRACE_POINT_OAM_ADJ:
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_MEP_INDEX))
            {
                uint32 ma_index = 0;
                value = watch_key->mep_index;
                cmd = DRV_IOW(DbgOamHdrAdj_t, DbgOamHdrAdj_mepIndex_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                cmd = DRV_IOW(DbgOamApsSwitch_t, DbgOamApsSwitch_mepIndex_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                cmd = DRV_IOW(DbgOamApsProcess_t, DbgOamApsProcess_mepIndex_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                value = 0;
                cmd = DRV_IOW(DbgOamHdrAdj_t, DbgOamHdrAdj_debugSessionEn_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                value = 1;
                cmd = DRV_IOW(DbgOamApsSwitch_t, DbgOamApsSwitch_debugUseMepIdx_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                cmd = DRV_IOW(DbgOamApsProcess_t, DbgOamApsProcess_debugUseMepIdx_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                cmd = DRV_IOW(DbgOamHdrAdj_t, DbgOamHdrAdj_debugUseMepIdx_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                cmd = DRV_IOR(DsEthMep_t, DsEthMep_isBfd_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, watch_key->mep_index, cmd, &value));
                if (value)
                {
                    cmd = DRV_IOR(DsBfdMep_t, DsBfdMep_maIndex_f);
                }
                else
                {
                    cmd = DRV_IOR(DsEthMep_t, DsEthMep_maIndex_f);
                }
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, watch_key->mep_index, cmd, &ma_index));
                value = 1;
                cmd = DRV_IOW(DsMa_t, DsMa_debugSessionEn_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, ma_index, cmd, &value));
            }
            else
            {
                value = 1;
                cmd = DRV_IOW(DbgOamHdrAdj_t, DbgOamHdrAdj_debugSessionEn_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                value = 0;
                cmd = DRV_IOW(DbgOamHdrAdj_t, DbgOamHdrAdj_debugUseMepIdx_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
            }
            break;
        case CTC_DIAG_TRACE_POINT_OAM_TX:
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_MEP_INDEX))
            {
                uint32 ma_index = 0;
                value = watch_key->mep_index;
                cmd = DRV_IOW(DbgOamTxProc_t, DbgOamTxProc_mepIndex_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                value = 1;
                cmd = DRV_IOW(DbgOamTxProc_t, DbgOamTxProc_debugUseMepIdx_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
                cmd = DRV_IOR(DsEthMep_t, DsEthMep_isBfd_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, watch_key->mep_index, cmd, &value));
                if (value)
                {
                    cmd = DRV_IOR(DsBfdMep_t, DsBfdMep_maIndex_f);
                }
                else
                {
                    cmd = DRV_IOR(DsEthMep_t, DsEthMep_maIndex_f);
                }
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, watch_key->mep_index, cmd, &ma_index));
                value = 1;
                cmd = DRV_IOW(DsMa_t, DsMa_debugSessionEn_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, ma_index, cmd, &value));
            }
            else
            {
                value = 1;
                cmd = DRV_IOW(DbgOamTxProc_t, DbgOamTxProc_debug1stPkt_f);
                CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
            }
            goto install_bsr;
            break;
        case CTC_DIAG_TRACE_POINT_SC_OAM_TX:
            cmd = DRV_IOR(FlexEOamUpdateCtl_t, DRV_ENTRY_FLAG);
            CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ds));
            SetFlexEOamUpdateCtl(V, debugSessionEn_f, &ds, 1);
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_CLIENT_ID))
            {
                if (MCHIP_FLEXE(lchip)->flexe_get_client_prop)
                {
                    CTC_ERROR_RETURN(MCHIP_FLEXE(lchip)->flexe_get_client_prop(lchip, watch_key->client_id,
                                                                               SYS_FLEXE_CLIENT_PROP_HW_CLIENT, &value));
                }
                SetFlexEOamUpdateCtl(V, dbgClientId_f, &ds, value);
            }
            cmd = DRV_IOW(FlexEOamUpdateCtl_t, DRV_ENTRY_FLAG);
            CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ds));
            break;
        case CTC_DIAG_TRACE_POINT_SC_OAM_RX:
            cmd = DRV_IOR(FlexEOamParserCtl_t, DRV_ENTRY_FLAG);
            CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ds));
            if (CTC_BMP_ISSET(watch_key->key_mask_bmp, CTC_DIAG_WATCH_KEY_MASK_CLIENT_ID))
            {
                if (MCHIP_FLEXE(lchip)->flexe_get_client_prop)
                {
                    CTC_ERROR_RETURN(MCHIP_FLEXE(lchip)->flexe_get_client_prop(lchip, watch_key->client_id,
                                                                               SYS_FLEXE_CLIENT_PROP_HW_CLIENT, &value));
                }
                SetFlexEOamParserCtl(V, dbgClientId_f, &ds, value);
            }
            SetFlexEOamParserCtl(V, ignoreOamTypeMatch_f, &ds, 1);
            SetFlexEOamParserCtl(V, ignoreSeqMatch_f, &ds, 1);
            cmd = DRV_IOW(FlexEOamParserCtl_t, DRV_ENTRY_FLAG);
            CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ds));
            break;
        default:
            break;
    }
    return CTC_E_NONE;
install_ipe:
    if (p_trace->mode == CTC_DIAG_TRACE_MODE_USER)
    {
        SetIpeUserIdFlowCam(V, g_0_isDebuggedPkt_f, &ds_flow_cam, 1);
        SetIpeUserIdFlowCam(V, g_1_isDebuggedPkt_f, &ds_flow_cam, 0x1);
    }
install_bsr:
    SetBufStoreDebugCam(V, g_0_isDebuggedPkt_f, &ds_buff_store_cam, 1);
    SetBufStoreDebugCam(V, g_1_isDebuggedPkt_f, &ds_buff_store_cam, 0x1);
    cmd = DRV_IOW(BufStoreDebugCam_t, DRV_ENTRY_FLAG);
    if(dpid==0 || dpid==1)
    {
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, dpid, cmd, &ds_buff_store_cam));
    }
    else
    {
        SYS_SET_TBL_ALL_DP(lchip, cmd, ds_buff_store_cam);
    }

    io_valid1 = 1;
    value =1;
    cmd = DRV_IOW(BufStoreDebugCtl_t, BufStoreDebugCtl_debugLookupEn_f);
    if(dpid==0 || dpid==1)
    {
          CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, dpid, cmd, &value));
    }
    else
    {
          SYS_SET_FIELD_TBL_ALL_DP(lchip, cmd, value);
    }
install_met:
    if (watch_point != CTC_DIAG_TRACE_POINT_TM_MET)
    {
        SetMetFifoDebugCam(V, g_0_isDebuggedPkt_f, &ds_met_fifo_cam, 1);
        SetMetFifoDebugCam(V, g_1_isDebuggedPkt_f, &ds_met_fifo_cam, 0x1);
    }
    else
    {
        value =0;
        cmd = DRV_IOW(BufStoreDebugCtl_t, BufStoreDebugCtl_debugLookupEn_f);
        SYS_SET_FIELD_TBL_ALL_DP(lchip, cmd, value);
    }
    cmd = DRV_IOW(MetFifoDebugCam_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ds_met_fifo_cam));
    io_valid2 = 1;
    value = 1;
    cmd = DRV_IOW(MetFifoCtl_t, MetFifoCtl_debugLookupEn_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
install_epe:
    if (watch_point == CTC_DIAG_TRACE_POINT_EPE_ADJ)
    {
        value =0;
        cmd = DRV_IOW(BufStoreDebugCtl_t, BufStoreDebugCtl_debugLookupEn_f);
        SYS_SET_FIELD_TBL_ALL_DP(lchip, cmd, value);
    }
    else
    {
        SetEpeHdrAdjustDebugCam(V, g_0_isDebuggedPkt_f, &ds_epe_dbg_cam, 1);
        SetEpeHdrAdjustDebugCam(V, g_1_isDebuggedPkt_f, &ds_epe_dbg_cam, 0x1);
    }

    cmd = DRV_IOW(EpeHdrAdjustDebugCam_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ds_epe_dbg_cam));
    if (!io_valid2)
    {
        cmd = DRV_IOW(MetFifoDebugCam_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ds_met_fifo_cam));
    }
    if (!io_valid1)
    {
        cmd = DRV_IOW(BufStoreDebugCam_t, DRV_ENTRY_FLAG);
        CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ds_buff_store_cam));
    }
    cmd = DRV_IOW(IpeUserIdFlowCam_t, DRV_ENTRY_FLAG);
    CTC_ERROR_RETURN(DRV_IOCTL(lchip, 0, cmd, &ds_flow_cam));

    value = 1;
    cmd = DRV_IOW(DebugSessionStatusCtl_t, DebugSessionStatusCtl_isFree_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
    cmd = DRV_IOW(EpeHdrAdjustChanCtl_t, EpeHdrAdjustChanCtl_debugIsFree_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
    cmd = DRV_IOW(EpeHdrAdjustCtl_t, EpeHdrAdjustCtl_debugLookupEn_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
    cmd = DRV_IOW(IpeUserIdFlowCtl_t, IpeUserIdFlowCtl_flowEn_f);
    CTC_ERROR_RETURN(DRV_FIELD_IOCTL(lchip, 0, cmd, &value));
    return CTC_E_NONE;
}

int32
sys_tmm_diag_get_pos(uint16 discard, uint8* pos)
{
    if (discard >= SYS_TMM_DISCARD_NETRX_START && discard <= SYS_TMM_DISCARD_NETRX_END)
    {
        *pos = CTC_DIAG_DROP_POS_NETRX;
    }
    else if (discard <= SYS_TMM_DISCARD_IPE_END)
    {
        *pos = CTC_DIAG_DROP_POS_IPE;
    }
    else if (discard >= SYS_TMM_DISCARD_BSR_START && discard <= SYS_TMM_DISCARD_BSR_END)
    {
        *pos = CTC_DIAG_DROP_POS_BSR;
    }
    else if (discard >= SYS_TMM_DISCARD_EPE_START && discard <= SYS_TMM_DISCARD_EPE_END)
    {
        *pos = CTC_DIAG_DROP_POS_EPE;
    }
    else if (discard >= SYS_TMM_DISCARD_NETTX_START && discard <= SYS_TMM_DISCARD_NETTX_END)
    {
        *pos = CTC_DIAG_DROP_POS_NETTX;
    }
    else 
    {
        *pos = CTC_DIAG_DROP_POS_OAM;
    }
    return CTC_E_NONE;
}
#endif
#endif

